Skip to content

lib-memory-dir.sh's no-jq Python-fallback drop marker can itself fail silently if mktemp fails #804

Closed

Description

@fdaviddpt

What

scripts/lib-memory-dir.sh's no-jq Python-fallback branch signals an untrusted-project-config
drop via a marker file (its own stdout/stderr are already redirected to /dev/null by the
caller, so they cannot carry a signal). If the mktemp call that creates THAT marker path itself
fails (a full or read-only $TMPDIR), the drop can happen with nothing logged -- reproducing, in
this one compound case, the exact silent fail-closed defect #748 fixed elsewhere.

Location

scripts/lib-memory-dir.sh:622:

_project_drop_marker=$(mktemp "${SYS_TMPDIR}/remember-config-drop-marker-XXXXXX" 2>/dev/null) || _project_drop_marker=""

Mechanism

When this mktemp fails, _project_drop_marker is empty. The Python subprocess then receives an
empty drop_marker_path argument, and its own if drop_marker_path: ... guard skips writing the
marker even when the untrusted project layer ALSO fails to load in that same invocation -- so the
drop happens with nothing logged. This needs BOTH mktemp and the project config to fail in the
same run to trigger, so it is a doubly-rare compound case, not the common path.

The code's own comment at this line already states the general tradeoff as deliberate: "tolerated
the same way every other mktemp-failure path in this file is (fall through, don't crash the merge
over the logging side-channel itself)" -- every OTHER mktemp call in this file (the sanitize
temp file, the merged-config temp file) accepts the identical silent-fallthrough shape on its own
mktemp failure, so this is not an isolated oversight so much as a known, accepted-elsewhere
pattern applied here too.

Why not fixed alongside #748

Found by the oss:auditor self-review during #748's own lane; ranked fails-to-preserve,
non-blocking, "can ship behind a trap.d fragment." Logged as
trap.d/748.marker-signal-dies-if-mktemp-fails.md. Still true at HEAD as of this curation pass
(2026-09-26).

What would settle it

Undecided, and worth a maintainer call rather than a guessed fix: whether a compound failure this
rare is worth a SECOND, independent signal (e.g. checking the Python subprocess's own exit code in
addition to the marker file, so a failure disclosure never depends on a second filesystem operation
succeeding), or whether the existing "every mktemp failure in this file is tolerated the same way"
precedent already covers it and this is working as designed.

[AI-generated]

Activity

  1. added
    priority:medium
    filed-by-loop
    lane-storage
    on Sep 26, 2026
  2. self-assigned this
    on Sep 26, 2026
  3. added a commit that references this issue on Sep 26, 2026
  4. removed their assignment
    on Sep 26, 2026
  5. added 8 commits that reference this issue on Sep 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    filed-by-looplane-storagepriority:medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions