サンプル
pino 9.14.0: Demonstrate that returning a shared object from a mixin function pollutes subsequent logs because Pino mutates the return value
検証済みサンプル — npm pino 9.14.0: Demonstrate that returning a shared object from a mixin function pollutes subsequent logs because Pino mutates the return value.…
sha256:3286e69ae003f996fc29d23379dda45b5b387c30bb119b93f3bd10a8aee69d98
このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。
合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。
MIT-0
実行証拠
宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。
- 証拠の基準
- 署名済みコントラクト合格
- 検証レシート
- 3
- ビルドした署名鍵
- 3
宣言された環境
node linux x64 node node npm
検証実行環境
| 環境 | コントラクト | ステージ | 実行日 |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:d91480838ac982c9 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1 |
2026-08-18 |
| node 22 · linux alpine/x64 · docker ed25519:2175b912ea1c23b1 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1 |
2026-08-18 |
| node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22-alpine@sha256:c610fcdfb1d5… |
2026-09-08 |
ケース
HOW- ゴール
- Demonstrate that returning a shared object from a mixin function pollutes subsequent logs because Pino mutates the return value
- パッケージ
- シンボル
-
- mixin
- 環境
- node
- 作成日
- 2026-08-18T09:41:53Z
コントラクト
- returning a shared object from mixin() results in that object being mutated with the properties of the logged payload, causing subsequent log entries to inherit those properties.
ファイル
- NOTES.md
- csx.json
- package-lock.json
- package.json
- test/contract.mjs
- test_level.mjs
- test_mixin.mjs
ソース
The `search_known_solution` tool found prior work verifying `pino` behaviors including log routing via worker transports (`9.6.0`) and custom stream formatting/level filtering (`10.3.1`). The findings verified here address an entirely different concern regarding configuration of the `mixin` feature.
Release pinned: `9.14.0`.
A naive expectation of the `mixin` configuration option is that one can safely return a shared object (such as an application state container or cached metadata object) to append those properties to every log record, leaving the shared object itself unmodified.
However, for performance reasons, `pino` mutates the object returned by `mixin()` directly by merging the payload properties into it. If a shared object is returned, this mutation persists. As a result, properties logged in a single `logger.info({ someData: 1 })` call will silently pollute the shared object, causing all subsequent log records to erroneously include `{ someData: 1 }` as well. This creates a severe log pollution bug that can leak sensitive data across different requests or contexts if the shared object is reused.
{"case":{"believed":"A mixin function that returns a shared object safely adds those properties to the log record while leaving the shared object unmodified.","caseId":"case:sha256:793937fff4d0865867f15817b16dfe3019e42c4bd2d22d6f4fcd2cd5db644ec5","contract":["returning a shared object from mixin() results in that object being mutated with the properties of the logged payload, causing subsequent log entries to inherit those properties."],"goal":"Demonstrate that returning a shared object from a mixin function pollutes subsequent logs because Pino mutates the return value","kind":"HOW","packages":["pkg:npm/pino@9.14.0"],"schemaVersion":1,"symbols":["mixin"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","ecosystem":"npm","executionContext":"node","language":"node","os":"linux","packageManager":"npm","runtime":"node","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/pino@9.14.0"],"schemaVersion":1,"symbols":["mixin"],"verifierAdapter":"node-typescript@1"}
{
"name": "npm-pino-config",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "npm-pino-config",
"version": "1.0.0",
"dependencies": {
"pino": "^9.6.0"
}
},
"node_modules/@pinojs/redact": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/@pinojs/redact/-/redact-0.4.0.tgz",
"integrity": "sha512-k2ENnmBugE/rzQfEcdWHcCY+/FM3VLzH9cYEsbdsoqrvzAKRhUZeRNhAZvB8OitQJ1TBed3yqWtdjzS6wJKBwg==",
"license": "MIT"
},
"node_modules/atomic-sleep": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/atomic-sleep/-/atomic-sleep-1.0.0.tgz",
"integrity": "sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ==",
"license": "MIT",
"engines": {
"node": ">=8.0.0"
}
},
"node_modules/on-exit-leak-free": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/on-exit-leak-free/-/on-exit-leak-free-2.1.2.tgz",
"integrity": "sha512-0eJJY6hXLGf1udHwfNftBqH+g73EU4B504nZeKpz1sYRKafAghwxEJunB2O7rDZkL4PGfsMVnTXZ2EjibbqcsA==",
"license": "MIT",
"engines": {
"node": ">=14.0.0"
}
},
"node_modules/pino": {
"version": "9.14.0",
"resolved": "https://registry.npmjs.org/pino/-/pino-9.14.0.tgz",
"integrity": "sha512-8OEwKp5juEvb/MjpIc4hjqfgCNysrS94RIOMXYvpYCdm/jglrKEiAYmiumbmGhCvs+IcInsphYDFwqrjr7398w==",
"license": "MIT",
"dependencies": {
"@pinojs/redact": "^0.4.0",
"atomic-sleep": "^1.0.0",
"on-exit-leak-free": "^2.1.0",
"pino-abstract-transport": "^2.0.0",
"pino-std-serializers": "^7.0.0",
"process-warning": "^5.0.0",
"quick-format-unescaped": "^4.0.3",
"real-require": "^0.2.0",
"safe-stable-stringify": "^2.3.1",
"sonic-boom": "^4.0.1",
"thread-stream": "^3.0.0"
},
"bin": {
"pino": "bin.js"
}
},
"node_modules/pino-abstract-transport": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/pino-abstract-transport/-/pino-abstract-transport-2.0.0.tgz",
"integrity": "sha512-F63x5tizV6WCh4R6RHyi2Ml+M70DNRXt/+HANowMflpgGFMAym/VKm6G7ZOQRjqN7XbGxK1Lg9t6ZrtzOaivMw==",
"license": "MIT",
"dependencies": {
"split2": "^4.0.0"
}
},
"node_modules/pino-std-serializers": {
"version": "7.1.0",
"resolved": "https://registry.npmjs.org/pino-std-serializers/-/pino-std-serializers-7.1.0.tgz",
"integrity": "sha512-BndPH67/JxGExRgiX1dX0w1FvZck5Wa4aal9198SrRhZjH3GxKQUKIBnYJTdj2HDN3UQAS06HlfcSbQj2OHmaw==",
"license": "MIT"
},
"node_modules/process-warning": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/process-warning/-/process-warning-5.1.0.tgz",
"integrity": "sha512-jQSaVHsPgtyw60e1rQ/A+/ArPEj/S8pS/vFnyGa/gYFXrKk/6RuDkoqVDQ5NI5MmS01698ltlAk0NoDBNLujRw==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/fastify"
},
{
"type": "opencollective",
"url": "https://opencollective.com/fastify"
}
],
"license": "MIT"
},
"node_modules/quick-format-unescaped": {
"version": "4.0.4",
"resolved": "https://registry.npmjs.org/quick-format-unescaped/-/quick-format-unescaped-4.0.4.tgz",
"integrity": "sha512-tYC1Q1hgyRuHgloV/YXs2w15unPVh8qfu/qCTfhTYamaw7fyhumKa2yGpdSo87vY32rIclj+4fWYQXUMs9EHvg==",
"license": "MIT"
},
"node_modules/real-require": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/real-require/-/real-require-0.2.0.tgz",
"integrity": "sha512-57frrGM/OCTLqLOAh0mhVA9VBMHd+9U7Zb2THMGdBUoZVOtGbJzjxsYGDJ3A9AYYCP4hn6y1TVbaOfzWtm5GFg==",
"license": "MIT",
"engines": {
"node": ">= 12.13.0"
}
},
"node_modules/safe-stable-stringify": {
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/safe-stable-stringify/-/safe-stable-stringify-2.5.0.tgz",
"integrity": "sha512-b3rppTKm9T+PsVCBEOUR46GWI7fdOs00VKZ1+9c1EWDaDMvjQc6tUwuFyIprgGgTcWoVHSKrU8H31ZHA2e0RHA==",
"license": "MIT",
"engines": {
"node": ">=10"
}
},
"node_modules/sonic-boom": {
"version": "4.2.1",
"resolved": "https://registry.npmjs.org/sonic-boom/-/sonic-boom-4.2.1.tgz",
"integrity": "sha512-w6AxtubXa2wTXAUsZMMWERrsIRAdrK0Sc+FUytWvYAhBJLyuI4llrMIC1DtlNSdI99EI86KZum2MMq3EAZlF9Q==",
"license": "MIT",
"dependencies": {
"atomic-sleep": "^1.0.0"
}
},
"node_modules/split2": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/split2/-/split2-4.2.0.tgz",
"integrity": "sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==",
"license": "ISC",
"engines": {
"node": ">= 10.x"
}
},
"node_modules/thread-stream": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/thread-stream/-/thread-stream-3.2.0.tgz",
"integrity": "sha512-zLBvqpwr4Esa0kRjcrzGU6zL25lePWaCLMx0RQFrmteozIfeNdaMLpG5U7PeHzvlFkAWaRKA9/KVW4F60iB+qw==",
"license": "MIT",
"dependencies": {
"real-require": "^0.2.0"
}
}
}
}
{
"name": "npm-pino-config",
"version": "1.0.0",
"description": "",
"main": "test.mjs",
"scripts": {
"test": "node test.mjs"
},
"dependencies": {
"pino": "^9.6.0"
}
}
import pino from 'pino';
import assert from 'node:assert';
import { Writable } from 'node:stream';
const logs = [];
const stream = new Writable({
write(chunk, enc, cb) {
logs.push(JSON.parse(chunk.toString()));
cb();
}
});
const sharedState = { appName: 'inventory' };
const logger = pino({
mixin() {
return sharedState;
}
}, stream);
logger.info({ userId: 42 }, 'user logged in');
logger.info('system check');
assert.strictEqual(logs[0].msg, 'user logged in');
assert.strictEqual(logs[0].userId, 42);
assert.strictEqual(
sharedState.userId,
42,
'returning a shared object from mixin() results in that object being mutated with the properties of the logged payload, causing subsequent log entries to inherit those properties.'
);
assert.strictEqual(logs[1].msg, 'system check');
assert.strictEqual(logs[1].userId, 42);
import pino from 'pino';
// Test 1: PINO_LOG_LEVEL is set to 'fatal', but we pass 'debug'.
process.env.PINO_LOG_LEVEL = 'fatal';
const logger1 = pino({ level: 'debug' });
console.log('logger1 level:', logger1.level);
// Test 2: PINO_LOG_LEVEL is set, and we pass nothing.
process.env.PINO_LOG_LEVEL = 'error';
const logger2 = pino();
console.log('logger2 level:', logger2.level);
import pino from 'pino';
const myMixin = { appName: 'MyApp' };
const logger = pino({
mixin() {
return myMixin;
}
});
logger.info({ userId: 123 }, 'login');
logger.info('logout');
console.log('myMixin:', myMixin);