8000 Deflake test_write_what_where_shadowstack by zardus · Pull Request #124 · angr/rex · GitHub
[go: up one dir, main page]

Skip to content

Deflake test_write_what_where_shadowstack - #124

Merged
twizmwazin merged 1 commit into
masterfrom
fix/deflake-write-what-where-shadowstack
Aug 27, 2026
Merged

twizmwazin merged 1 commit into
masterfrom
fix/deflake-write-what-where-shadowstack

Conversation

@zardus
@zardus zardus commented Aug 22, 2026 •
Copy link
Copy Markdown
Member

THIS MESSAGE WAS GENERATED BY AN AUTOMATED PROCESS

test_write_what_where_shadowstack fails intermittently in the shared ci / Test (0) shard, so it reddens pull requests in repositories that cannot reach CGC exploit synthesis at all — angr/angr#6854, a decompiler change, among them.

The exploit is fine; the assertion is a coin flip. The challenge leaks through send_all(1, message, strlen(message)), and the synthesized write-what-where points message into the CGC magic page. povsim asks for exactly four bytes and accepts the run only if they occur in the page it dumped. When the seeded flag page holds a zero inside those four, strlen stops early, the read runs on into the challenge's own filler, and povsim is handed ZZZZ.

test_binary reseeds the flag page every run, so no leak offset avoids it. Pinning the page with enable_randomness=False makes the assertion about the exploit rather than about the seed.

Validation: #124 (comment)

session: pr-review

@angr-bot
Copy link
Copy Markdown
Member

Corpus decompilation diffs can be found at angr/dec-snapshots@master...angr/rex_124

@twizmwazin twizmwazin left a comment
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

remove the comments you added, then lgtm

@zardus
zardus commented Aug 27, 2026
Copy link
Copy Markdown
Member Author

THIS MESSAGE WAS GENERATED BY AN AUTOMATED PROCESS

Validation record for the flake characterization behind this change.

All trials on one x86-64 Linux host under an unrelated concurrent workload (load average 5-46, mean 22); angr, cle, claripy, pyvex, archinfo at master, rex, angrop, archr, tracer, povsim at master; one forked process per trial, matching CI's pytest --forked.

Measurement Runs Failures Rate
Randomly seeded trials of one generated POV 900 8 0.89%
Full test end to end, before 480 10 2.08%
Full test end to end, after (enable_randomness=False) 240 0 0%
Pinned flag page, one generated POV 200 0 0%

The decisive arm is paired, which keeps machine load out of the comparison: 240 trials, each generating one exploit and then evaluating both assertions in the same process, moments apart — 7 failures for the old assertion, 0 for the new.

Predicted rate from the mechanism: a zero byte anywhere in the four leaked bytes, 1 - (255/256)**4, about 1.5% of seeds. The observed end-to-end rate sits inside that.

Two things this is not:

  • Not load sensitivity. Failing runs spent 0.15-1.67 s inside test_binary; the slowest of 217 runs spent 4.27 s, and across the paired 240 the slowest was 5.34 s, against povsim's 15 s negotiation budget.
  • Not angrop. The Fail to set register: esi to: 0x41414141 lines in the failure output are emitted on passing runs too — pytest prints captured logs only for failures, which is what makes them look like a symptom. A local passing run emits all five verbatim.

Confirmed CI instance: angr/angr#6854, run 31921312936, job 95102083567, 2026-08-16; the same shard passed on a later commit of that branch. Sampling the shared CI found 1 failure of this test in ~239 ci / Test (0) shard executions across angr/cle and angr/angr over 12 days (0.42%), inside the confidence interval of the local rate.

If you would rather assert reliability explicitly than pin the seed, test_binary(times=N) returns a list of N results, and sum(results) >= N - 1 over times=10 would flake about once in 12,000 runs.

The test asserted a single randomly seeded run of the generated CGC type-2
POV, which is a coin flip rather than a test of the exploit.

Mechanism. The challenge binary leaks through

    send_all(1, message, strlen(message))

and the exploit's write-what-where points `message` at the CGC magic page.
povsim asks for exactly 4 bytes (read_size is hard-coded in
cgc_pov_simulator._do_binary_negotiation_type_2) and accepts the run only if
those 4 bytes occur in the magic page. When the seeded flag page holds a zero
byte inside the four bytes being leaked, strlen stops early, the POV's 4-byte
read runs on into the challenge's own `send_all(1, &foo, 4)` filler, and
povsim sees 0x5a5a5a5a ("ZZZZ") instead of flag data:

    received flag data 0x5a5a5a5a
    pov successful? False

That is 1 - (255/256)**4, about 1.5% of seeds, and it is a property of the
target's strlen-bounded leak primitive, not of the exploit: no choice of
offset avoids it, because the flag page is regenerated from a fresh seed on
every run. Measured over 900 randomly seeded runs of one generated POV:
8 failures (0.89%). Measured end to end, generating a fresh exploit each
time: 3 failures in 217 runs (1.38%). Failing runs took 0.15-1.67s inside
test_binary, so povsim's 15s negotiation budget is not involved.

Fix: pin the flag page with enable_randomness=False so the assertion is about
the exploit rather than about the seed. 240/240 end-to-end runs pass with it,
against 3 failures in the paired randomly seeded arm.

The `Fail to set register: ... to: 0x41414141` errors angrop logs during this
test are unrelated noise. They are emitted on passing runs too; pytest only
prints captured logs for failures, which is why they look like a symptom.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@zardus
zardus force-pushed the fix/deflake-write-what-where-shadowstack branch from e831e12 to f967dc7 Compare August 27, 2026 14:28
@zardus
zardus commented Aug 27, 2026
Copy link
Copy Markdown
Member Author

THIS MESSAGE WAS GENERATED BY AN AUTOMATED PROCESS

Done — comments removed in f967dc7. The diff is now the single enable_randomness=False argument and nothing else.

The reasoning moved to the description and to the validation comment (#124 (comment)), which is where the measurements belong rather than in the test body.

session: pr-review

@twizmwazin
twizmwazin merged commit 07d9525 into master Aug 27, 2026
15 checks passed
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

0