Runtime cache does not enforce Project directory permissions and ownership
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 52/100
Research direction
Start by reading netbox_scripts/runtime/cache.py, especially _ensure_private_root() and materialize_revision(), then inspect the storage code used by store.write_revision(). Reproduce the reported umask and permissive-directory cases and check the Project, staging, and lock file modes and ownership. Done means new directories and lock files have private permissions, unsafe existing Project directories are rejected, and a verified published revision cannot be replaced.
Written by the indexing model from the issue text.
Description
Plugin Version
v0.0.1
NetBox Version
v4.7.1
Python Version
3.12
Steps to Reproduce
Using one account in NetBox's Django shell (python manage.py shell):
- Prepare a valid revision containing
example.pyand write it to anInMemoryStorageusingnetbox_scripts.storage.store.write_revision(). - Create a temporary cache root and set its permissions to
0755withchmod(). - Set the process umask to
0002and callnetbox_scripts.runtime.cache.materialize_revision()with that root. Restore the previous umask in afinallyblock. - Inspect
<root>/<storage_key>/and its.<digest>.lockfile. - Create a second cache root with permissions
01777. Inside it, create<storage_key>/and set its permissions to0777. - Materialize the same revision using the second root.
Expected Behavior
New Project and staging directories are created with private permissions.
Before using an existing Project directory, the plugin checks that it belongs to the NetBox account or root and rejects permissions that let other accounts modify its contents.
The published revision remains protected from replacement after verification.
Observed Behavior
In the first case, the Project directory is created with permissions 0775 and the lock file with 0664. Project and staging directory creation follows the process umask.
In the second case, materialization succeeds inside the existing 0777 Project directory.
Source inspection shows that _ensure_private_root() checks the cache root and its ancestors, but the Project directory is accepted through mkdir(exist_ok=True) without checking its owner or permissions.
When another local account can traverse the cache path, writable Project directories allow it to replace the published revision directory despite the revision's read-only permissions.
The default cache root, when created by the plugin with permissions 0700, prevents other accounts from reaching these directories. The exposure requires a cache location that other accounts can traverse.
- Dominant language
- Python
- Stars
- 8
- Forks
- 0
- Avg merge
- 11h 41m
- Merged PRs (30d)
- 38
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from netbox-community/netbox-scripts
-
app: scripts Bucket: Improve status: backlog type: documentation
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
netbox-community/netbox-scripts#80 ·
Maintainers usually reply within 1 day
-
app: scripts Bucket: KTLO severity: low status: backlog type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
netbox-community/netbox-scripts#76 ·
Maintainers usually reply within 1 day
-
app: scripts Bucket: KTLO severity: medium status: backlog type: bug
Difficulty 4/5 3-5 days Newbie friendliness 55/100
netbox-community/netbox-scripts#112 ·
Maintainers usually reply within 1 day
-
app: scripts Bucket: KTLO severity: low status: backlog type: bug
Difficulty 4/5 3-5 days Newbie friendliness 45/100
netbox-community/netbox-scripts#111 ·
Maintainers usually reply within 1 day
-
app: scripts Bucket: KTLO severity: low status: backlog type: bug
Difficulty 4/5 3-5 days Newbie friendliness 45/100
netbox-community/netbox-scripts#100 ·
Maintainers usually reply within 1 day
All issues in netbox-community/netbox-scripts
Similar issues
-
documentation good first issue
Difficulty 1/5 Under an hour Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
MarketSquare/robotframework-browser#5479 ·
Maintainers usually reply within 1 day
-
Visual COBOL: missing 11.0 and 12.0, and 9.0 date differs from Rocket Software's lifecycle pageOpen
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
endoflife-date/endoflife.date#11561 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
OCA/l10n-brazil#5602 ·
Maintainers usually reply within 1 day
-
documentation review-2.0.0
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
dkuenzel/meshcore-home-gateway#106 ·
Maintainers usually reply within 1 day