Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/security-redact-cookies-in-logs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/cli-kit': patch
---

Redact Cookie and Set-Cookie headers from debug logs to prevent sensitive session data leakage.
19 changes: 19 additions & 0 deletions packages/cli-kit/src/private/node/api/headers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,25 @@ describe('common API methods', () => {
- Content-Type: application/json"
`)
})

test('sanitizedHeadersOutput removes the headers that include cookies', () => {
// Given
const headers = {
'User-Agent': 'useragent',
Cookie: 'session=abc',
'Set-Cookie': 'session=def',
'content-type': 'application/json',
}

// When
const got = sanitizedHeadersOutput(headers)

// Then
expect(got).toMatchInlineSnapshot(`
" - User-Agent: useragent
- content-type: application/json"
`)
})
})

describe('GraphQLClientError', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli-kit/src/private/node/api/headers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class GraphQLClientError extends RequestClientError {
*/
export function sanitizedHeadersOutput(headers: Record<string, string>): string {
const sanitized: Record<string, string> = {}
const keywords = ['token', 'authorization', 'subject_token']
const keywords = ['token', 'authorization', 'subject_token', 'cookie']
Object.keys(headers).forEach((header) => {
if (keywords.find((keyword) => header.toLocaleLowerCase().includes(keyword)) === undefined) {
sanitized[header] = headers[header]!
Expand Down
Loading