Skip to content

fix(tcpusb): check AUTH signatures strictly with OpenSSL - #570

Merged
koral-- merged 1 commit into
masterfrom
fix/strict-signature-check
Oct 25, 2026
Merged

koral-- merged 1 commit into
masterfrom
fix/strict-signature-check

Conversation

@koral--

@koral-- koral-- commented Oct 25, 2026

Copy link
Copy Markdown
Member

Fixes the open node-forge alert (GHSA-86w9-cpqp-85rv). No fixed node-forge exists: every version up to 1.4.0 is affected.

The problem

The TCP-USB bridge checked the client's AUTH signature with node-forge's PKCS#1 v1.5 verify. node-forge accepts garbage inside the DigestAlgorithm sequence, which lets anyone forge a signature for a key with exponent 3 (adb keys use 65537, but parsePublicKey accepts 3 too). The new test shows node-forge 1.4.0 accepting such a signature.

The fix

The bridge now removes the padding with crypto.publicDecrypt, where OpenSSL checks it strictly. What's left has to equal the SHA-1 DigestInfo of the token byte for byte, so there's nothing left to parse. Exponent 3 keys keep working. node-forge is still used for parsing keys and fingerprints, which the advisory doesn't affect.

Testing

  • New tests:
    • A signature that was changed is rejected.
    • An exponent 3 key still authenticates.
    • Garbage in the DigestInfo is rejected, both for a known key and for a key the client sends.
    • The two garbage tests fail without the fix.
  • 259 passing, 13 pending. tsc, lint and Prettier are clean.
  • End to end, with the packed package in stf on an API 30 emulator:
    • Before the key is registered, adb connect to stf's remote debug URL gives device unauthorized, and stf offers to add the key.
    • After adding it, adb -s <url> shell works.

🤖 Generated with Claude Code

node-forge's PKCS#1 v1.5 verification accepts garbage inside the
DigestAlgorithm sequence, which lets anyone forge signatures for
exponent 3 keys (GHSA-86w9-cpqp-85rv). No fixed node-forge exists.

The bridge now removes the padding with crypto.publicDecrypt, which
checks it strictly, and compares what's left byte for byte with the
SHA-1 DigestInfo of the token. node-forge is still used to parse keys.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Karol Wrótniak <[email protected]>
@koral--
koral-- merged commit 5e40595 into master Oct 25, 2026
6 checks passed
@koral--
koral-- deleted the fix/strict-signature-check branch October 25, 2026 00:49
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.

1 participant