Skip to content

feat(sdk-core): add console sanitization for sensitive data#8016

Open
rishikeshdadam136 wants to merge 2 commits intomasterfrom
WP-7503
Open

feat(sdk-core): add console sanitization for sensitive data#8016
rishikeshdadam136 wants to merge 2 commits intomasterfrom
WP-7503

Conversation

@rishikeshdadam136
Copy link

Adds automatic console log sanitization in test/staging environments to prevent token exposure for all BitGoJS SDK users. Sanitizes 6 sensitive keys (token, bearer, prv, privatekey, password, otp) and v2x bearer tokens before logging.

Technical changes:

  • Created sanitizeLog.ts with recursive sanitization logic
  • Created consoleOverride.ts to intercept console.log/error/warn/info
  • Imported in sdk-core/src/index.ts for full SDK coverage

Ticket: WP-7503

Implements custom logger to prevent token exposure in test/staging environments.
Replaced 111 console statements across 52 files with logger that redacts sensitive
keys (token, bearer, prv, privatekey, password, otp) and v2x bearer tokens.

Technical changes:
- Created sanitizeLog.ts with recursive sanitization (O(1) Set lookups)
- Created logger.ts with conditional sanitization (test/staging only)
- Exported logger from sdk-core for SDK-wide access
- Updated 52 files across express, sdk-core, sdk-api, abstract, coin, and utility modules

Ticket: WP-7503
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please revert changes to utxo-bin, it's a dev tool that needs to print input verbatim

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we do not want to introduce a dep to @bitgo/sdk-core here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert please

Implements custom logger to prevent token exposure in test/staging environments.
Replaced 111 console statements across 52 files with logger that redacts sensitive
keys (token, bearer, prv, privatekey, password, otp) and v2x bearer tokens.

Technical changes:
- Created sanitizeLog.ts with recursive sanitization (O(1) Set lookups)
- Created logger.ts with conditional sanitization (test/staging only)
- Exported logger from sdk-core for SDK-wide access
- Updated 52 files across express, sdk-core, sdk-api, abstract, coin, and utility modules

Ticket: WP-7503
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the sdk-core dep is pretty massive

better move this to a more focused, lightweight package @bitgo/logger

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok i will move it @bitgo/logger.
Thank you

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will push again after all the changes

const SENSITIVE_KEYS = new Set([
'token',
'bearer',
'prv',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'prv',
'prv',
'xprv',

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants