step-examples/12-11-adversarial/Ad113.stp
Sources
- bug-reporter language: "STEP loader reads wrong file in sibling pair", "symlink swap between input and main STEP"
- CWE-367 (TOCTOU)
- cad/research sibling-pair convention (`.input.stp` + `.stp`)
Sender
deduced — adversarial filesystem context, or a multi-process pipeline where one process renames a sibling file between the receiver's two reads
Description
The cad/research validator pairs each `.stp` fixture with an optional `.input.stp` sibling that captures the producer-side input. A receiver that reads `.input.stp` first (to populate its "expected input" oracle) and then reads `.stp` (the actual fixture) performs at least two independent path resolutions. If either path is a symlink that an attacker swaps between the two reads, the receiver sees a `.input.stp` that does not match the `.stp` it ultimately processes; the textbook TOCTOU race applied to the sibling-pair convention. A receiver that reports outcomes against the wrong input grades the wrong fixture. Bug-reporter language: "sibling-pair files don't match", "symlink swap on STEP test fixture", "validator races on .input.stp".
Reproducer recipe
a `.input.stp` and `.stp` pair where one path is a symlink under attacker control; between the validator's read of `.input.stp` and its open of `.stp`, the symlink target is swapped. The bytes alone cannot demonstrate this; the demonstration requires a concurrent attacker process. **Important**: this fixture documents the scenario in a header comment but does NOT actually create a symlink in the repo (cross-platform unfriendly).
Expected kernel behavior
open both paths atomically in a single resolve, or open the directory once and use `openat()` for both files; never re-resolve absolute paths between the two reads; refuse to follow symlinks in the fixture tree unless explicitly enabled.
Notes
Sibling-pair-specific cousin of Ad106 (general EXTERNAL_FILE TOCTOU). Provenance tier: cross-file-state; bytes alone cannot demonstrate this defect; the symptom is a filesystem race between path-resolution operations. The static fixture is document-only: no real symlink is created in the repo. **See also**: Ad106, Ad114, Ad115. **OCC behavior**: silently accepts (no diagnostic, empty result); outside catalog's allowed set ({reject}). Kernel-bug witnessed: receivers must reject this fixture per the catalog's stated invariant.
Expected validation
occt=empty/empty gmsh=empty ifc=schema_n/a
Provenance tier
cross-file-state — defect not fully embodied in fixture bytes.
Byte assertions
contains(b'TOCTOU') or contains(b'symlink') or contains(b'sibling')contains(b'.input.stp') or contains(b'race')
Tier-3 assertions
load == "ok"
Cross-references
Live oracle output
No live oracle data — run _run_corpus to populate.
Fixture content
Show fixture bytes
1ISO-10303-21; 2/* Ad113 - Symlink swap between read of .input.stp and read of .stp 3 * (sibling-pair TOCTOU) 4 * Defect: the cad/research validator pairs each .stp fixture with an 5 * optional .input.stp sibling capturing the producer-side input. A 6 * receiver that reads .input.stp first (to populate its expected-input 7 * oracle) and then reads .stp (the actual fixture) performs at least 8 * two independent path resolutions. If either path is a symlink that 9 * an attacker swaps between the two reads, the receiver sees a 10 * .input.stp that does not match the .stp it ultimately processes - 11 * the textbook TOCTOU race applied to the sibling-pair convention. 12 * 13 * IMPORTANT: this fixture documents the scenario in this header 14 * comment; no real symlink is created in the repository (cross-platform 15 * unfriendly). Provenance tier: cross-file-state. */ 16HEADER; 17FILE_DESCRIPTION(('Ad113 - sibling-pair TOCTOU race symlink swap .input.stp vs .stp'),'2;1'); 18FILE_NAME('Ad113.stp','2026-05-02T00:00:00',(''),(''),'cad-research-suite','',''); 19FILE_SCHEMA(('AUTOMOTIVE_DESIGN { 1 0 10303 214 1 1 1 1 }')); 20ENDSEC; 21DATA; 22/* Witness body: the TOCTOU race lives in the receiver-side filesystem 23 between the .input.stp read and the .stp read. The bug-reporter 24 searchable terms (TOCTOU, symlink, sibling, .input.stp, race) are 25 in this file's header and comments. The actual demonstration 26 requires a concurrent attacker process that swaps a symlink target 27 between the receiver's two reads. 28 29 No real symlink is created in this repo - cross-platform support 30 for symlinks in source control is poor (Windows + WSL + git config 31 each treat them differently). */ 32/* sibling-pair race: .input.stp symlink swapped before .stp open */ 33#1=APPLICATION_CONTEXT('automotive_design'); 34#10=CARTESIAN_POINT('benign',(0.0,0.0,0.0)); 35ENDSEC; 36END-ISO-10303-21;