Skip to content

Commit 5f7f39b

Browse files
[Security] Redact cookies from debug logs
Add 'cookie' to the list of redacted keywords in `sanitizedHeadersOutput` to prevent session data leakage in debug logs. Update tests to verify redaction.
1 parent 7078668 commit 5f7f39b

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

packages/cli-kit/src/private/node/api/headers.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ describe('common API methods', () => {
8585
authorization: 'token',
8686
'Content-Type': 'application/json',
8787
'X-Shopify-Access-Token': 'token',
88+
Cookie: 'session=123',
89+
'Set-Cookie': 'session=456',
8890
}
8991

9092
// When

packages/cli-kit/src/private/node/api/headers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export class GraphQLClientError extends RequestClientError {
3333
*/
3434
export function sanitizedHeadersOutput(headers: Record<string, string>): string {
3535
const sanitized: Record<string, string> = {}
36-
const keywords = ['token', 'authorization', 'subject_token']
36+
const keywords = ['token', 'authorization', 'subject_token', 'cookie']
3737
Object.keys(headers).forEach((header) => {
3838
if (keywords.find((keyword) => header.toLocaleLowerCase().includes(keyword)) === undefined) {
3939
sanitized[header] = headers[header]!

0 commit comments

Comments
 (0)