Files
hyperframes/skills
Michael Wang 0495a57f76 fix(media-use): refuse links under .media before reserving, writing or recording (#8327)
* fix(media-use): refuse links under .media before reserving, writing or recording

A received project could carry links at .media, at a type folder, at the
next asset name or its .tmp name, or at the preferences store's temp
names, and resolve or prefs record wrote through them to files outside
the project.

- ownMediaDir now checks every folder down to the type folder, making
  each one level at a time, before the lock, the allocator, the record
  append or a project preference write touches anything inside it.
- The allocator ignores ids past nine digits, so a planted huge id can't
  push it back onto a name the project holds, and it skips any name that
  already exists.
- The asset writers and the LUT .tmp writers create new files only.
- The preferences store writes through replaceFile, a random temp name
  created exclusively and renamed into place.

Both copies of manifest.mjs and prefs-store.mjs change together.

* test(media-use): read the preferences file through one no-follow handle

The test checked the file's type and then read it by path, which CodeQL
reports as a check-then-use race. Open it once without following a link
and check and read through that handle.

* fix(media-use): keep a failed write's error when replaceFile can't remove its temp file

The preferences store now writes through replaceFile. Its old write made
temp cleanup best-effort, so a cleanup error never hid the write error,
and the store's tests guard that. replaceFile now does the same.

* fix(media-use): leave freezeUrl's write as it was

CodeQL's http-to-file-access rule flags every write of downloaded bytes,
and main already carries that alert on this line. Adding the wx flag only
re-keyed it as new. The reserved name freezeUrl writes is already checked
free in a checked folder, so the line goes back to main's text; copying a
local file keeps COPYFILE_EXCL.

* Revert "fix(media-use): leave freezeUrl's write as it was"

This reverts commit 1427e73ec2.
2026-11-22 01:59:05 +00:00
..