Skip to content

Implement sensitive input detection and testing for chat features#6987

Merged
cakesoft-vaibhav merged 5 commits into
feat/AiChatfrom
feat/sensitive-input-guard
May 26, 2026
Merged

Implement sensitive input detection and testing for chat features#6987
cakesoft-vaibhav merged 5 commits into
feat/AiChatfrom
feat/sensitive-input-guard

Conversation

@Parsh

@Parsh Parsh commented May 25, 2026

Copy link
Copy Markdown
Collaborator

This pull request introduces a comprehensive, testable frontend guard against leaking sensitive Bitcoin key material (BIP39 mnemonics, extended keys, WIF keys) through the Ask Keeper AI chat and GitHub issue draft submission flows. The previous inline regex is replaced with a robust utility that detects actual cryptographic data formats, not just keywords, and blocks their transmission. The detection logic is centralized, unit-tested, and applied both at chat send and draft submission time.

Sensitive Data Detection Utility:

  • Created src/utils/helpAiSensitiveData.ts exporting detectSensitiveInput and detectSensitiveInDraft, implementing detection for BIP39 mnemonic sequences, extended (xprv/xpub) keys, WIF keys, and keywords, with clear result types and messages. [1] [2]
  • Added src/constants/bip39WordSet.ts, a static Set<string> of all 2048 BIP39 English words for fast, dependency-free mnemonic detection. [1] [2]

Detection Logic and Integration:

  • Replaced the inline SENSITIVE_INPUT_PATTERN regex in HelpAiChat.tsx with the new utility, ensuring all chat messages and draft submissions are scanned for sensitive data before transmission. [1] [2]
  • Implemented draft scanning in submitDraftIssue(), blocking GitHub issue submissions containing sensitive data and showing an explanatory toast. [1] [2] [3]

Requirements and Testing:

  • Added detailed requirements and scenarios to the spec: block 8+ consecutive BIP39 words, actual extended key strings (prefix + 100+ base58 chars), and WIF keys (50–52 base58 chars starting with 5/K/L/c), but do not block keyword-only messages.
  • Added comprehensive unit tests for all detection cases, including true/false positives for mnemonics, keys, keywords, and draft content.

Design Decisions:

  • Detection is synchronous, client-side only, and does not scan AI replies or perform real-time inline warnings (send-time only). Keyword-only messages are not blocked to avoid false positives. [1] [2]

Migration and Rollback:

  • All changes are frontend-only, with no backend or data format impact. Reverting to the prior state is trivial if needed.

These changes ensure robust, testable protection against accidental leakage of sensitive Bitcoin key material through both chat and draft submission features.

@Parsh
Parsh requested a review from cakesoft-vaibhav May 25, 2026 15:28
@cakesoft-vaibhav
cakesoft-vaibhav merged commit 8745854 into feat/AiChat May 26, 2026
1 check failed
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.

2 participants