# GHSA-F9J8-MV7V-85GR: Redaction silently skips built-in objects, so a secret inside an Error, a Map or a Set is written to the log in clear

- Database: GitHub
- Severity: CVSS 5.5 (Medium)
- Published: 2026-11-26
- Modified: 2026-11-26

## Affected versions

- @logtape/redaction (npm): from 1.3.5, through 2.4.2

## Description

## Summary

Both redactors in `@logtape/redaction` refuse to look inside built-in objects:

```js
function isBuiltInObject(value) {
  return value instanceof Error || value instanceof Date || value instanceof RegExp
    || value instanceof Map || value instanceof Set || value instanceof WeakMap
    || value instanceof WeakSet || value instanceof Promise || value instanceof ArrayBuffer
    || (typeof SharedArrayBuffer !== "undefined" && value instanceof SharedArrayBuffer)
    || ArrayBuffer.isView(value)
}
```

`pattern.js` returns such a value untouched, and `field.js` does the same at four separate call sites. The object is then handed to the sink and rendered by `util.inspect`, which prints an `Error`'s message, a `Map`'s entries and a `Set`'s members in full.

Logging an `Error` is the most common structured log call there is. With the documented setup and the built-in patterns, a credit card number, a JWT, an email address or a US SSN inside an error message reaches the log in cleartext, and nothing in the output indicates that redaction was skipped.

Verified against **2.4.2**, the current published version, on Node 22. The same code ships on JSR as `@logtape/redaction` at the same version; I could only file the npm row because GitHub's private-report API rejects `jsr` as an ecosystem value, so please add the JSR row on the draft as your previous advisories do. Reported through the private advisory channel your `SECURITY.md` asks for; nothing has been published anywhere.

## Details

### What was run

The setup is the one from <https://logtape.org/manual/redaction>, with no options beyond the built-in patterns:

```js
await configure({
  sinks: {
    console: getConsoleSink({
      formatter: redactByPattern(defaultConsoleFormatter,
        [CREDIT_CARD_NUMBER_PATTERN, EMAIL_ADDRESS_PATTERN, JWT_PATTERN, US_SSN_PATTERN])
    })
  },
  loggers: [{ category: ["app"], lowestLevel: "debug", sinks: ["console"] }]
})
```

Six of eight shapes leak:

| what is logged | result |
|---|---|
| a plain string in the message | redacted |
| a plain object | redacted |
| **an `Error`** | **PAN, JWT, email and SSN all in clear** |
| **an `Error` inside a plain object** | **in clear** |
| **an `Error` reached through `.cause`** | **in clear** |
| **an `Error` inside an array** | **in clear** |
| **a `Map`** | **in clear** |
| **a `Set`** | **in clear** |

### Field-based redaction has the same hole, and it is worse there

`redactByField` with `DEFAULT_REDACT_FIELDS` redacts a field named `token` and a nested field named `password` correctly. But an `Error` carrying an own property **literally named `token`** is not redacted, because the built-in check runs before the field names inside it are ever examined:

```
{ error: Error: boom { token: 'eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhZG1pbiJ9.Zm9vYmFy' } }
```

A `Map` whose key is literally `secret` is likewise untouched. Attaching context to an error — `Object.assign(err, { token, requestId })` — is a common pattern, and it defeats the field list.

Field-based redaction does not scan free-form text such as `Error.message`. The defect is that it also skips fields whose names match the configured rules, such as an `Error`'s `token` property or a `Map` entry keyed by `secret`.

### Why this is a security boundary and not an accuracy limitation

The documentation lists the real limits of each mode: pattern-based "may produce false positives" and "operates after formatting"; field-based "cannot detect sensitive data in free-form text" and "may miss sensitive data with unexpected field names". It also says pattern-based redaction "recursively scans object and array values".

None of those caveats describes this. The field name is not unexpected — in the `Object.assign` case it is exactly `token`. The data is not free-form text in a message template — it is a value in the properties. The documentation does not mention `Error`, `Map` or `Set` anywhere, so an operator who reads it has no way to know that the single most common object in an error log is exempt.

`Date` and `RegExp` are correctly excluded; they carry no user data and traversing them is pointless. The problem is that `Error`, `Map` and `Set` are in the same list, and those three routinely carry exactly the data redaction exists to catch.

### Suggested fix

- **Treat `Error` as a traversable shape with known fields.** Run the patterns over `message`, `stack`, and recurse into `cause` and any own enumerable properties, then rebuild an `Error` carrying the redacted values. Field-based redaction should likewise match field names against an error's own properties.
- **Traverse `Map` and `Set`.** Redact keys and values for `Map`, members for `Set`, and return the same kind of collection.
- **Keep `Date`, `RegExp`, `Promise`, `ArrayBuffer` and typed arrays excluded** — they hold no string data worth scanning, and that part of the list is right.
- **If any type stays exempt, say so in the documentation**, under the existing cons lists, and consider emitting a one-time meta-logger warning when an exempt object is encountered — the same mechanism already used for `maxDepth` and `maxProperties`.

A regression test that logs `new Error(\`card=${PAN}\`)` and asserts the PAN does not appear in the sink output would pin it, along with the `Object.assign(err, { token })` case for the field mode.

## Proof of concept

Self-contained, one container, `--network none`. The package is installed from the registry and is not modified. The values are inert: a Luhn-valid test PAN, a throwaway JWT, an `example.com` address and a placeholder SSN.

```sh
set -e
D=$(mktemp -d) && cd "$D"
cat > Dockerfile <<'POCFILE0'
FROM node:22-bookworm-slim
ARG VERSION=2.4.2
WORKDIR /app
RUN npm init -y >/dev/null 2>&1 && npm pkg set type=module >/dev/null 2>&1 \
 && npm install --ignore-scripts @logtape/logtape @logtape/redaction@${VERSION} >/dev/null 2>&1
COPY poc-logtape-redaction-builtin-bypass.mjs /app/poc.mjs
CMD ["node","/app/poc.mjs"]
POCFILE0
cat > poc-logtape-redaction-builtin-bypass.mjs <<'POCFILE1'
// @logtape/redaction skips built-in objects, so a secret inside an Error, a Map
// or a Set is written to the log in clear.
//
// Everything runs inside one container. The "secrets" are a Luhn-valid test PAN,
// a throwaway JWT, an example.com address and a placeholder SSN: all inert.
import { inspect } from 'node:util'
import { configure, getConsoleSink, getLogger, defaultConsoleFormatter } from '@logtape/logtape'
import {
  redactByPattern, redactByField, DEFAULT_REDACT_FIELDS,
  CREDIT_CARD_NUMBER_PATTERN, EMAIL_ADDRESS_PATTERN, JWT_PATTERN, US_SSN_PATTERN
} from '@logtape/redaction'

const PAN = '4242424242424242'
const JWT = 'eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhZG1pbiJ9.Zm9vYmFy'
const EMAIL = 'victim@example.com'
const SSN = '123-45-6789'
const SECRETS = [['PAN', PAN], ['JWT', JWT], ['EMAIL', EMAIL], ['SSN', SSN]]

// Node renders console's %o with util.inspect, so the harness must too.
// JSON.stringify hides an Error's message and would make these look redacted.
const flatten = args => args.map(x =>
  typeof x === 'string' ? x : inspect(x, { depth: 12, breakLength: Infinity, colors: false })
).join(' ')

let sawRaw = []
for (const m of ['log', 'info', 'warn', 'error', 'debug']) console[m] = (...a) => sawRaw.push(a)
const emit = (...a) => process.stdout.write(a.join(' ') + '\n')

await configure({
  sinks: {
    console: getConsoleSink({
      formatter: redactByPattern(defaultConsoleFormatter,
        [CREDIT_CARD_NUMBER_PATTERN, EMAIL_ADDRESS_PATTERN, JWT_PATTERN, US_SSN_PATTERN])
    })
  },
  loggers: [{ category: ['app'], lowestLevel: 'debug', sinks: ['console'] }]
})
const log = getLogger(['app'])

const rows = []
function run(label, fn) {
  sawRaw = []
  fn()
  const flat = flatten(sawRaw.flat())
  rows.push([SECRETS.filter(([, v]) => flat.includes(v)).map(([n]) => n), label, flat])
}

run('a plain string in the message',  () => log.error`payment failed card=${PAN} jwt=${JWT} email=${EMAIL} ssn=${SSN}`)
run('a plain object',                 () => log.error`payment failed ${{ card: PAN, jwt: JWT }}`)
run('an Error',                       () => log.error`payment failed ${new Error(`card=${PAN} jwt=${JWT} email=${EMAIL} ssn=${SSN}`)}`)
run('an Error inside an object',      () => log.error`payment failed ${{ error: new Error(`card=${PAN}`) }}`)
run('an Error reached via .cause',    () => log.error`payment failed ${new Error('outer', { cause: new Error(`card=${PAN}`) })}`)
run('an Error inside an array',       () => log.error`payment failed ${[new Error(`card=${PAN}`)]}`)
run('a Map',                          () => log.error`payment failed ${new Map([['card', PAN]])}`)
run('a Set',                          () => log.error`payment failed ${new Set([PAN])}`)

const v = (await import('@logtape/redaction/package.json', { with: { type: 'json' } })).default.version
emit(`@logtape/redaction ${v}`)
emit('setup: getConsoleSink({ formatter: redactByPattern(defaultConsoleFormatter, [...built-in patterns]) })\n')
emit('--- pattern-based redaction ---')
for (const [leaked, label, flat] of rows) {
  emit(`${leaked.length ? '*** IN CLEAR: ' + leaked.join(',') : '    redacted             '}  ${label}`)
  emit('        ' + flat.replace(/%c|%o|color: [a-z-]+;|background-color: [a-z-]+;/g, '').replace(/ at file:[^\s]+/g, '').replace(/\s+/g, ' ').trim().slice(0, 190))
}

let seen = null
const wrapped = redactByField((record) => { seen = record }, { fieldPatterns: DEFAULT_REDACT_FIELDS })
function fieldCase(label, properties) {
  seen = null
  wrapped({ category: ['f'], level: 'error', timestamp: Date.now(), message: ['m'], rawMessage: 'm', properties })
  const flat = inspect(seen?.properties ?? seen, { depth: 12, breakLength: Infinity })
  const leaked = SECRETS.filter(([, v]) => flat.includes(v)).map(([n]) => n)
  emit(`${leaked.length ? '*** IN CLEAR: ' + leaked.join(',') : '    redacted             '}  ${label}`)
  emit('        ' + flat.replace(/ at file:[^\s]+/g, '').replace(/\s+/g, ' ').slice(0, 170))
}
emit('\n--- field-based redaction, DEFAULT_REDACT_FIELDS ---')
fieldCase('a field named "token"',                { token: JWT })
fieldCase('a nested field named "password"',      { ctx: { password: PAN } })
fieldCase('an Error whose message holds the PAN', { error: new Error(`card=${PAN}`) })
fieldCase('an Error with an own "token" property', { error: Object.assign(new Error('boom'), { token: JWT }) })
fieldCase('a Map with a "secret" entry',          { m: new Map([['secret', PAN]]) })
POCFILE1
docker build -q -t logtape-poc . >/dev/null
docker run --rm --network none --cap-drop ALL --security-opt no-new-privileges logtape-poc
echo; echo "cleanup: docker rmi -f logtape-poc >/dev/null; rm -rf $D"
```

Output, verbatim and abbreviated only where a stack trace was cut:

```
@logtape/redaction 2.4.2
setup: getConsoleSink({ formatter: redactByPattern(defaultConsoleFormatter, [...built-in patterns]) })

--- pattern-based redaction ---
    redacted               a plain string in the message
        ERR app payment failed card= jwt= email= ssn= XXXX-XXXX-XXXX-XXXX [JWT REDACTED] REDACTED@EMAIL.ADDRESS XXX-XX-XXXX
    redacted               a plain object
        ERR app payment failed { card: 'XXXX-XXXX-XXXX-XXXX', jwt: '[JWT REDACTED]' }
*** IN CLEAR: PAN,JWT,EMAIL,SSN  an Error
        ERR app payment failed Error: card=4242424242424242 jwt=eyJhbGciOiJIUzI1NiJ9… email=victim@example.com ssn=123-45-6789
*** IN CLEAR: PAN  an Error inside an object
        ERR app payment failed { error: Error: card=4242424242424242 }
*** IN CLEAR: PAN  an Error reached via .cause
        ERR app payment failed Error: outer { [cause]: Error: card=4242424242424242 }
*** IN CLEAR: PAN  an Error inside an array
        ERR app payment failed [ Error: card=4242424242424242 ]
*** IN CLEAR: PAN  a Map
        ERR app payment failed Map(1) { 'card' => '4242424242424242' }
*** IN CLEAR: PAN  a Set
        ERR app payment failed Set(1) { '4242424242424242' }

--- field-based redaction, DEFAULT_REDACT_FIELDS ---
    redacted               a field named "token"
        {}
    redacted               a nested field named "password"
        { ctx: {} }
*** IN CLEAR: PAN  an Error whose message holds the PAN
        { error: Error: card=4242424242424242 }
*** IN CLEAR: JWT  an Error with an own "token" property
        { error: Error: boom { token: 'eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhZG1pbiJ9.Zm9vYmFy' } }
*** IN CLEAR: PAN  a Map with a "secret" entry
        { m: Map(1) { 'secret' => '4242424242424242' } }
```

One note on method, because it changed the result. An earlier version of this harness rendered captured values with `JSON.stringify`, under which an `Error` serialises to `{}` and the nested cases looked redacted. Node's console renders `%o` with `util.inspect`, which prints the message. The numbers above are from the `util.inspect` version, which is what a real sink writes.

## Impact

An application that configures `@logtape/redaction` to keep cardholder data, national identifiers, tokens or email addresses out of its logs still writes all of them in clear whenever the value travels inside an `Error`, a `Map` or a `Set` — and `catch (error) { logger.error\`failed ${error}\` }` is the ordinary way to log a failure. Upstream SDKs routinely put request bodies, query strings and headers into error messages, so the value that lands there is frequently the one the operator most wanted masked.

The failure is silent. The log looks redacted because the surrounding fields are, the meta logger emits nothing, and the gap is not documented. Logs are shipped to aggregators, retained, and read by people and services that are not trusted with the data itself.

The CVSS score assumes that a user with local log-reading privileges, but no authorization to access the underlying secrets, can recover valid credentials from the logs.

---

*Submitted through the GitHub private-reporting API. The web form's "I used AI assistance to find or write up this report" checkbox has no API equivalent, so stating it here: AI assistance was used to find and write up this report. Every claim above was verified by running the proof of concept against the published artifact.*

## References

- https://github.com/dahlia/logtape/security/advisories/GHSA-f9j8-mv7v-85gr

Page: https://cve.now/GHSA-F9J8-MV7V-85GR

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
