Skip to content

🐛 fix(strict): reject foreign-owned sentinels - #992

Merged
gaborbernat merged 5 commits into
tox-dev:mainfrom
gaborbernat:fix/strict-foreign-sentinel
Nov 20, 2026
Merged

gaborbernat merged 5 commits into
tox-dev:mainfrom
gaborbernat:fix/strict-foreign-sentinel

Conversation

@gaborbernat

@gaborbernat gaborbernat commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

In a POSIX sticky directory such as /tmp, a strict lock now accepts a sentinel only when the caller or the directory owner owns it. The sentinel keeps legacy soft locks out while a strict holder is active. The sticky bit lets the file's owner remove that name during the hold. Linux unlink rules, ANT-2026-DYZMWIDJ.

Before publishing its claim, StrictSoftFileLock checks ownership using the descriptor it opened for the sentinel. On Linux, an account can use its own sentinel when its UID matches the kernel's overflow value and ownership can be verified. A sentinel owned by any other account raises SoftFileLockProtocolError. The directory owner can remove the conflicting sentinel, or callers can move their lock to a private directory. Linux ownership check in #1099.

An older sentinel writable by another account needs replacing while all clients are stopped. Tightening its mode with fchmod leaves existing writable descriptors usable. On the next acquisition the lock creates a sentinel without group or other write permission.

Reported by OSS Scanner (ANT-2026-DYZMWIDJ).

@gaborbernat gaborbernat added bug security Fixes a published or draft security advisory labels Nov 20, 2026
@gaborbernat
gaborbernat marked this pull request as draft November 20, 2026 15:32
@gaborbernat
gaborbernat force-pushed the fix/strict-foreign-sentinel branch from 48673c8 to e6408fc Compare November 20, 2026 15:48
@gaborbernat
gaborbernat changed the base branch from main to fix/mapped-sticky-owner November 20, 2026 15:48
@gaborbernat
gaborbernat force-pushed the fix/strict-foreign-sentinel branch 3 times, most recently from 276eda0 to 4d8b7bb Compare November 20, 2026 16:39
@gaborbernat
gaborbernat marked this pull request as ready for review November 20, 2026 18:24
@gaborbernat
gaborbernat marked this pull request as draft November 20, 2026 19:33
@gaborbernat
gaborbernat force-pushed the fix/strict-foreign-sentinel branch 2 times, most recently from ff20d1f to c04a385 Compare November 20, 2026 19:59
@gaborbernat
gaborbernat marked this pull request as ready for review November 20, 2026 21:37
@gaborbernat
gaborbernat marked this pull request as draft November 20, 2026 22:00
@gaborbernat
gaborbernat deleted the branch tox-dev:fix/mapped-sticky-owner November 20, 2026 22:00
An attacker who owns the compatibility sentinel in a shared sticky directory
can remove it during a strict hold. A legacy soft lock can then enter while
the strict lock remains held.

Refuse that sentinel before treating it as part of a strict acquisition.
Pass the open sentinel to the sticky-directory ownership check so a caller
whose UID matches the overflow value can use its own sentinel.
@gaborbernat gaborbernat reopened this Nov 20, 2026
@gaborbernat
gaborbernat changed the base branch from fix/mapped-sticky-owner to main November 20, 2026 22:03
@gaborbernat
gaborbernat force-pushed the fix/strict-foreign-sentinel branch from c04a385 to 442f184 Compare November 20, 2026 22:08
@gaborbernat
gaborbernat marked this pull request as ready for review November 20, 2026 22:41
@gaborbernat
gaborbernat merged commit 7daf40d into tox-dev:main Nov 20, 2026
49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug security Fixes a published or draft security advisory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant