Ad106 — `EXTERNAL_FILE` URI resolves through a symlink (TOCTOU race)

§12.11 adversarial (sub-class: TOCTOU)

spec-violation adversarial

Sources

Sender

deduced — adversarial filesystem context, or a multi-process pipeline where one process writes a file and another renames the path between check and open

Description

An EXTERNAL_FILE entry references a sibling Part-21 file via a path. A receiver that follows the path performs at minimum two filesystem operations: a stat / access check (to verify the file exists, is the right type, fits a size budget) and an open (to read the bytes). On systems where the path resolves through a symlink, the symlink target may change between the check and the open; the classic TOCTOU race. A receiver that validates the stat result then opens the path can read a different file than it validated. Bug-reporter language: "STEP file follows symlink", "external-file resolves to wrong path", "TOCTOU race in STEP load".

Reproducer recipe

a STEP file whose REFERENCE / EXTERNAL_FILE clause names a path `/tmp/parts/widget.stp`; the receiver-side filesystem is set up so `/tmp/parts/widget.stp` is a symlink that the attacker can swap between the check and the open. The STEP body alone establishes only the path-naming side; the demonstration requires the receiver-side filesystem manipulation.

Expected kernel behavior

open the path once and stat the resulting file descriptor; never re-resolve the path between check and open. Refuse to follow symlinks unless explicitly enabled. Reject EXTERNAL_FILE paths that resolve outside a configured root directory.

Notes

Provenance tier: cross-file-state; bytes alone cannot demonstrate this defect; the symptom is a filesystem-race between path-resolution operations on the receiver side. The static fixture encodes only the path-naming precondition; the symlink-swap requires receiver-side filesystem manipulation. **OCC behavior**: emits a diagnostic but produces no shape (warn-and-proceed by oracle, but result is empty); 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

Tier-3 assertions

Live oracle output

No live oracle data — run _run_corpus to populate.

Fixture content

Show fixture bytes
1ISO-10303-21;
2/* Ad106: EXTERNAL_FILE URI resolves through a symlink; receiver performs stat then open — TOCTOU race; symlink target may change between check and open, causing receiver to read a different file than it validated; receiver must open path once and stat the resulting fd; must not re-resolve path between check and open; must refuse to follow symlinks unless explicitly enabled; must reject EXTERNAL_FILE paths resolving outside configured root; CWE-367; ISO 10303-21 Ed.3 §8 REFERENCE/EXTERNAL_FILE; GEOMETRIC_CURVE_SET IS model entity — OCC yields empty */
3HEADER;
4FILE_DESCRIPTION(('Ad106'),'2;1');
5FILE_NAME('Ad106.stp','2026-06-17T00:00:00',(''),(''),'cad-research-suite','','');
6FILE_SCHEMA(('AUTOMOTIVE_DESIGN { 1 0 10303 214 3 1 1 }'));
7ENDSEC;
8DATA;
9#1=CARTESIAN_POINT('',(0.0,0.0,0.0));
10#2=GEOMETRIC_CURVE_SET('',(#1));
11#3=EXTERNAL_FILE('companion_widget',('/tmp/parts/widget.stp'),'application/step',$);
12#4=/* TOCTOU race payload:
13   EXTERNAL_FILE path: /tmp/parts/widget.stp
14   Receiver checks access('/tmp/parts/widget.stp') then
15   open('/tmp/parts/widget.stp') — two separate syscalls.
16   Between the stat and the open, an attacker swaps the symlink:
17     /tmp/parts/widget.stp -> /tmp/parts/safe.stp  (at stat time)
18     /tmp/parts/widget.stp -> /etc/shadow          (at open time)
19   Receiver reads /etc/shadow despite validating /tmp/parts/safe.stp.
20   Fix: open-then-fstat; never re-resolve path after initial open. */
21CARTESIAN_POINT('toctou_note',(0.0,0.0,0.0));
22ENDSEC;
23REFERENCE;
24/* EXTERNAL_FILE /tmp/parts/widget.stp resolves through a symlink;
25   TOCTOU race: symlink target can be swapped between stat and open.
26   companion file: widget.stp */
27ENDSEC;
28END-ISO-10303-21;