Add config to exclude `value` from `Context` to prevent ingestion of secrets into logs
- Dominant language
- JavaScript
- Stars
- 21.2k
- Forks
- 1.5k
- Avg merge
- 4h 57m
- Merged PRs (30d)
- 14
Description
#### Support plan
* *is this issue currently blocking your project?* (yes/no): no
* *is this issue affecting a production system?* (yes/no): yes
#### Context
* *node version*: any
* *module version*: 17+
* *environment* (e.g. node, browser, native): node
* *used with* (e.g. hapi application, another framework, standalone, ...): standalone (affects all)
* *any other relevant information*: .
#### What problem are you trying to solve?
The default errors from failing joi validations contain the value that was under validation. If a developer captures the error in their logs, this can lead to sensitive information leaking into logs through `errors[i].context.value`.
```
[1] {
[1] "message": "\"users[0].passwordOrSecureField\" length must be 12 characters long",
[1] "path": [
[1] "users",
[1] 0,
[1] "passwordOrSecureField"
[1] ],
[1] "type": "string.length",
[1] "context": {
[1] "limit": 12,
[1] "value": "super-secret-value-should-not-be-in-logs",
[1] "label": "users[0].passwordOrSecureField",
[1] "key": "passwordOrSecureField"
[1] }
[1] }
```
#### Do you have a new or modified API suggestion to solve the problem?
This issue could be resolved by adding a custom error constructor. If this feature already exists, it would be useful to include mentions in the documentation.
Contributor guide
Research direction
Start by tracing how Joi validation errors construct errors[i].context and expose context.value, then review the existing error API and documentation. Done means a documented configuration or error-construction option can exclude the validated value while retaining the other error details.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- security
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100