Skip to content

lib-memory-dir.sh and lib-env-cache.sh carry the same predictable-tmp truncation class #427 fixed, and one of them writes a config that can hold an OAuth token #429

Closed

Description

@fdaviddpt

Reported by lane 427's self-review while fixing the same class in scripts/doctor.sh. Out of that lane's scope, so it is filed rather than fixed there.

Symptom

A pre-seeded symlink at a predictable path in a shared temp directory is opened and truncated as the invoking user. scripts/lib-memory-dir.sh then writes a merged config to that path -- and per its own adjacent comment that config can carry haiku.oauth_token, a live credential. So the exposure is not only truncation of an attacker-chosen file; it may also place credential-bearing content at an attacker-chosen destination.

Location

  • scripts/lib-memory-dir.sh:274 (and the mktemp/umask-then-write path at :274-278)
  • scripts/lib-env-cache.sh:80 and :194-195 -- the later (umask 077; : > "$_t") shape

Both are reached from nearly every entry point: doctor.sh sources lib-memory-dir.sh in its --json branch, and save-session.sh and the hooks resolve paths through the same chain.

Mechanism

The shell follows symlinks when opening a redirection target and truncates on open, before any byte is written or read. umask 077 constrains the mode of a file the shell creates; it does nothing about a path that already exists as a symlink. Lane 427's reproduction of the bare class:

bash -c '(umask 077; : > /tmp/pocdir/link)'   # link -> victim.txt
# victim.txt is now 0 bytes

#427 fixed exactly this shape in doctor.sh by routing both sites through mktemp, matching save-session.sh's existing convention. These two files were not in that lane and were not touched.

Ranking is deliberately left open. The truncation half is the same shape the round-one release audit called unranked for doctor.sh. The credential half is not the same finding: if a merged config carrying haiku.oauth_token can be written to an attacker-chosen path, that is discloses, which the ranking table marks blocking. Whether the write actually reaches the symlinked destination -- rather than failing or landing elsewhere -- is the fact that decides which, and it is not established here.

What would settle it

Trace whether lib-memory-dir.sh's merged-config write can land at a symlink's target with the token in it, or whether an intermediate step defeats that. If it can, this is a blocking row and the 0.24.0 tag waits on it too. If it cannot, it is the same truncation class as #427 and the fix is the same: route every temp path through mktemp, and let #427's class-pin test (test_no_script_builds_a_shared_tmpdir_path_from_pid) cover these files once it lands.

Activity

  1. added
    priority:high
    on Aug 29, 2026
  2. self-assigned this
    on Aug 29, 2026
  3. added 4 commits that reference this issue on Aug 29, 2026
  4. added 9 commits that reference this issue on Sep 12, 2026
  5. added 3 commits that reference this issue on Oct 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

priority:high

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions