fix(security): require distinct Fernet key, WS revocation fail-closed, salt_ops input validation, RBAC+SSRF guards (closes #578)#584
Merged
Conversation
…, salt_ops input validation, RBAC+SSRF guards (closes #578) - platform_settings_svc: _fernet_key raises RuntimeError in non-dev when FERNET_SECRET_KEY is absent; dev-only JWT-derive fallback emits a loud warning. Includes key-migration instructions in the comment block. - webssh get_current_user_ws: any exception from is_token_revoked now raises ValueError (fail-closed) instead of silently passing (degrade-open). - salt_ops: _validate_state_name (dotted-name regex) and _validate_minion_ids (_MINION_ID_RE, mirrors salt_keys.py) guard both /apply and /cmd endpoints; globs, wildcards, commas, and shell metacharacters are rejected with 422. - nodes.py: GET /{id}, /{id}/facts, /{id}/packages scoped from bare get_current_user to require_role("viewer","operator","admin"). - security.py: _ssrf_safe_url helper rejects file/ftp/non-http schemes and numeric IPs in loopback/private/link-local/metadata ranges before integration-status fires urllib.request.urlopen. - tests/unit/test_security_578.py: 23 new unit tests covering all five fixes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
# Conflicts: # VERSION # frontend/package.json
Coverage Report✅ 81.8% on Gate passed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
_fernet_key()raisesRuntimeErrorat startup in non-development environments whenFERNET_SECRET_KEYis absent, preventing silent key derivation fromJWT_SECRET. Dev mode retains the fallback with a loud warning. Key-migration instructions added inline.get_current_user_wsnow re-raises any non-ValueErrorexception fromis_token_revokedas aValueError, rejecting the WebSocket connection instead of degrading open when Redis is unavailable._validate_state_name(dotted-name allowlist regex) and_validate_minion_ids(_MINION_ID_RE, mirrorssalt_keys.py) guard both/applyand/cmdendpoints. Globs, wildcards, commas, path traversal, and shell metacharacters are rejected with HTTP 422.GET /nodes/{id},/facts,/packagesupgraded from bareget_current_usertorequire_role("viewer", "operator", "admin")._ssrf_safe_url()helper added tosecurity.py; called beforeurllib.request.urlopeninintegration-status. Rejects non-http/https schemes and numeric IPs in loopback/private/link-local/metadata ranges (127.0.0.0/8, 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, 169.254.0.0/16, ::1).Test plan
tests/unit/test_security_578.py— 23 new unit tests, all passingpytest tests/unit/ -q— 2167 passed, 0 failuresruff check+ruff format --check— 0 findings on changed filesCloses #578
🤖 Generated with Claude Code