Skip to content

fix(gateway): fail closed when auth_pair bearer RNG fails - #92

Closed
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/high-severity-issues-f272
Closed

cursor[bot] wants to merge 1 commit into
mainfrom
cursor/high-severity-issues-f272

Conversation

@cursor

@cursor cursor Bot commented Sep 18, 2026

Copy link
Copy Markdown

Summary

  • auth_pair now checks generate_random_hex and returns -1 on RNG/OOM failure before touching auth_tokens.json or clearing the pending pairing code.
  • Regression test forces crypto_read_urandom failure and asserts no tokens file write, pending code retained, and a later successful pair.

Bug

On main @ d367477, auth_pair ignored generate_random_hex failure. Trigger: /dev/urandom open/read failure or malloc failure inside the helper (PoC via crypto_test_force_urandom_fail). Impact: pairing returned success with an uninitialized/empty bearer, wrote [""] (or garbage) to auth_tokens.json, and consumed the pairing code so retry required manual file cleanup. Distinct from #71 (O_TRUNC wipe after successful hex gen) and #72 (auth cleanup UAF).

Test plan

  • make test_auth && ./build/test_auth
  • PoC: force urandom fail → auth_pair returns -1, no tokens file, pending code still pairs

Changelog

  • Unreleased Security note added.
Open in Web View Automation 

auth_pair ignored generate_random_hex failures, so urandom/OOM left an
uninitialized stack buffer as the bearer, wrote it to auth_tokens.json,
and burned the pairing code. Check the RNG result before mutating store
state and keep the pending code usable for retry.

Co-authored-by: esadrianno <esadrianno@gmail.com>
@adriannoes

Copy link
Copy Markdown
Collaborator

Superseded by #98 (rewrite contra development).

@adriannoes adriannoes closed this Sep 21, 2026
@adriannoes
adriannoes deleted the cursor/high-severity-issues-f272 branch September 22, 2026 21:17
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