Ad115 — Directory-entry race between `stat()` and `open()` on STEP fixture path

§12.11 adversarial (sub-class: TOCTOU / directory race)

P2 — spec deviation (no data loss)

adversarial

Sources

Sender

deduced — adversarial filesystem context where a directory entry is replaced between two filesystem operations on the same path

Description

A receiver that performs a path-based `stat()` on a fixture (to enforce a max-size budget, or a "regular file only" check, or a "this is the file we expected" hash check), then performs a separate path-based `open()`, races against any process that can swap the directory entry between the two syscalls. On a multi-tenant build host, an attacker replaces the directory entry (via `rename()`) so `stat()` sees a small benign file and `open()` returns a file descriptor on a much larger or hostile file. Distinct from Ad113 (sibling-pair race) and Ad114 (symlink-following): this entry is the directory-entry-swap vector even when no symlink is present. Bug-reporter language: "stat-vs-open race in STEP loader", "directory swap during validation", "rename() race on fixture path".

Reproducer recipe

a STEP fixture lives at a path whose containing directory is writable by an attacker; the attacker `rename()`s a small benign STEP file into place before the receiver's `stat()` and a hostile/oversized file into place before the receiver's `open()`. The bytes alone cannot demonstrate this; the demonstration requires a concurrent attacker process. The fixture in this catalog documents the scenario in a header comment.

Expected kernel behavior

Heal and accept: open the path once and `fstat()` the resulting file descriptor; never re-resolve the path for any check after the open; treat all path-based file metadata as untrusted. Must not crash on TOCTOU race.

Notes

Third TOCTOU vector after Ad113 (sibling-pair race) and Ad114 (symlink-following) — separate axis (directory-swap, not symlink-swap). Provenance tier: cross-file-state — bytes alone cannot demonstrate this defect; the symptom requires a concurrent attacker process. The static fixture is document-only. **See also**: Ad106, Ad113, Ad114.

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

Tier-3 assertions

Cross-references

Ad106, Ad113, Ad114

Live oracle output

No live oracle data — run _run_corpus to populate.

Fixture content

Show fixture bytes
1ISO-10303-21;
2/* Ad115 - Directory-entry race between stat() and open() on STEP fixture path
3 * Defect: a receiver that performs a path-based stat() on a fixture
4 * (to enforce a max-size budget, or a regular-file-only check, or a
5 * "this is the file we expected" hash check), then performs a separate
6 * path-based open(), races against any process that can swap the
7 * directory entry between the two syscalls. On a multi-tenant build
8 * host, an attacker rename()s a small benign file into place before
9 * the receiver's stat() and a hostile/oversized file into place
10 * before the receiver's open(). Distinct from Ad113 (sibling-pair
11 * race) and Ad114 (symlink-following): this entry is the directory-
12 * entry-swap vector even when no symlink is present.
13 *
14 * IMPORTANT: this fixture documents the scenario in this header
15 * comment. The race requires a concurrent attacker process; no
16 * filesystem manipulation is performed by this fixture.
17 * Provenance tier: cross-file-state. */
18HEADER;
19FILE_DESCRIPTION(('Ad115 - stat-vs-open directory-entry race on STEP path'),'2;1');
20FILE_NAME('Ad115.stp','2026-05-02T00:00:00',(''),(''),'cad-research-suite','','');
21FILE_SCHEMA(('AUTOMOTIVE_DESIGN { 1 0 10303 214 1 1 1 1 }'));
22ENDSEC;
23DATA;
24/* Witness body: the stat-vs-open TOCTOU defect lives in the receiver-
25   side filesystem and depends on a concurrent attacker process. The
26   bug-reporter searchable terms (TOCTOU, directory, race, rename,
27   stat, fstat) are in this file's header and comments.
28
29   The receiver should open the path once and fstat() the resulting
30   file descriptor; never re-resolve the path between two filesystem
31   operations. Path-based file metadata is untrusted on a multi-tenant
32   filesystem. */
33/* directory-entry rename() race between stat() and open() */
34#1=APPLICATION_CONTEXT('automotive_design');
35#10=CARTESIAN_POINT('benign',(0.0,0.0,0.0));
36ENDSEC;
37END-ISO-10303-21;