Skip to content

fix(rw): refuse another account's lock database - #970

Open
radhika1314 wants to merge 1 commit into
tox-dev:mainfrom
radhika1314:rw-foreign-database-owner
Open

radhika1314 wants to merge 1 commit into
tox-dev:mainfrom
radhika1314:rw-foreign-database-owner

Conversation

@radhika1314

Copy link
Copy Markdown
  1. _open_lock_database accepted any regular file at the database path. under a sticky parent such as /tmp, a database another account created first stays that account's to unlink, and it can do so during a hold. the next ReadWriteLock then creates a new database at the path and takes its sqlite locks on that inode, so two writers hold the lock at once.
  2. 🔒 fix(unix): refuse another account's lock file #968 closed this for UnixFileLock, but ReadWriteLock opens its database through its own helper and never reached foreign_owner. linux with fs.protected_regular=1 already fails the O_CREAT open with EACCES; macOS, and linux without that sysctl, open the file and use it.
  3. the open now runs the same foreign_owner check right after the non-regular-file check, before any private link is made, and raises PermissionError naming the uid. a database owned by the caller or by the directory's owner (root in /tmp) behaves as before.

the regression test mirrors the one #968 added for FileLock, and concepts.rst now names both locks. happy to fold this into a private advisory instead if you'd rather handle it the way #968 went.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant