Skip to content

feat(vault): add key-version header and rotation keyring support (#1770) - #2051

Closed
trivikramkalagi91-commits wants to merge 956 commits into
utksh1:mainfrom
trivikramkalagi91-commits:fix/layout-overlap-906-refactor-v2
Closed

feat(vault): add key-version header and rotation keyring support (#1770)#2051
trivikramkalagi91-commits wants to merge 956 commits into
utksh1:mainfrom
trivikramkalagi91-commits:fix/layout-overlap-906-refactor-v2

Conversation

@trivikramkalagi91-commits

@trivikramkalagi91-commits trivikramkalagi91-commits commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Description

Refactor VaultCrypto in backend/secuscan/vault.py to add explicit key-version headers, rotation keyring support, collision-safe legacy fallback decryption, key ID extraction, and strict payload length guards.

Key Technical Enhancements

  • Wire Format Specification (Version 1):
    Prepend magic header b"SV1:" (4 bytes) and raw key fingerprint (8 bytes) to newly encrypted blobs:
    $$\text{Wire Format} = \text{b"SV1:"}(4) ;||; \text{key_id_bytes}(8) ;||; \text{nonce}(12) ;||; \text{ciphertext} ;||; \text{auth_tag}(16)$$
  • Zero-Downtime Key Rotation & Keyring:
    Updated VaultCrypto.__init__(key, fallback_keys=[...]) to maintain an internal $\mathcal{O}(1)$ keyring lookup dictionary (_keyring: Dict[bytes, AESGCM]). Decryption extracts the key ID from the header to look up the correct key instantly without trial-and-error GCM tag failures.
  • Collision-Safe Legacy Fallback Protocol:
    If versioned decryption fails or if a legacy random 12-byte nonce coincidentally starts with b"SV1:" (1 in $2^{32}$ probability), decrypt() automatically falls back to attempting legacy decryption (nonce(12) || ciphertext), guaranteeing zero false-positive decryption failures for pre-existing secrets.
  • Out-of-Band Key ID Extraction:
    Added VaultCrypto.extract_key_id(cls, payload: str) -> Optional[str] to inspect base64url payloads and return the colon-separated hex key fingerprint without requiring secret decryption.
  • Explicit Payload Length Guards:
    Enforced strict minimum length guards ($\ge 28$ bytes for legacy, $\ge 40$ bytes for versioned) to fail fast on truncated inputs before touching underlying cryptographic routines.

Related Issues

Closes #1770

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

How Has This Been Tested?

Automated backend unit and integration test suites executed:

.\venv\Scripts\pytest testing/backend/unit/test_vault.py testing/backend/unit/test_vault_failure_messages.py testing/backend/unit/test_vault_fingerprint.py testing/backend/unit/test_vault_owner_isolation.py testing/backend/unit/test_vault_security.py -v

note :- though i have used ai to solve but i completely reviewed the changes made by ai tested it and then approved the changes 

Rakshak05 and others added 30 commits July 1, 2026 21:58
…1546)

Co-authored-by: tmdeveloper007 <tmdeveloper007@users.noreply.github.com>
Co-authored-by: tmdeveloper007 <tmdeveloper007@users.noreply.github.com>
Co-authored-by: tmdeveloper007 <tmdeveloper007@users.noreply.github.com>
…h1#1542)

Co-authored-by: tmdeveloper007 <tmdeveloper007@users.noreply.github.com>
Co-authored-by: tmdeveloper007 <tmdeveloper007@users.noreply.github.com>
Co-authored-by: tmdeveloper007 <tmdeveloper007@users.noreply.github.com>
Co-authored-by: tmdeveloper007 <tmdeveloper007@users.noreply.github.com>
Co-authored-by: tmdeveloper007 <tmdeveloper007@users.noreply.github.com>
Co-authored-by: tmdeveloper007 <tmdeveloper007@users.noreply.github.com>
…odule (utksh1#1524)

The extract_target helper in executor.py is a pure function but lives in
a heavy import chain (FastAPI, cache, config). Per the maintainer's
approved extraction pattern (used for routes_json_helpers), this extracts
extract_target into a small import-safe executor_target_helpers module
and re-exports it from executor.py so existing call sites keep working.

Closes utksh1#1389.

Co-authored-by: tmdeveloper007 <tmdeveloper007@users.noreply.github.com>
Co-authored-by: Tomeshwari-02 <tomeshwari903@gmail.com>
…h1#1563)

Co-authored-by: tmdeveloper007 <tmdeveloper007@users.noreply.github.com>
Co-authored-by: tmdeveloper007 <tmdeveloper007@users.noreply.github.com>
Co-authored-by: tmdeveloper007 <tmdeveloper007@users.noreply.github.com>
Co-authored-by: tmdeveloper007 <tmdeveloper007@users.noreply.github.com>
@utksh1 utksh1 added level:advanced 55 pts difficulty label for advanced contributor PRs type:security Security work category bonus label type:feature Feature work category bonus label area:backend Backend API, database, or service work area:security Security-sensitive implementation or tests labels Jul 24, 2026

@utksh1 utksh1 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The vault key-version work should be reviewed independently. Please remove the unrelated saved-views auth-test edits, retain only vault implementation/tests, and rebase before re-review.

Khanvilkarshravani27 and others added 3 commits July 24, 2026 15:10
Cover the scapy_recon plugin parser.py with targeted behavioural tests:

- Metadata contract: file existence, valid JSON, required fields, engine
  binary, target/type field declarations
- ARP output: host count, IP+MAC extraction, finding keys, category,
  severity, description content, metadata consistency, remediation
- ICMP output: host count, IP extraction, Unknown-MAC default
- Single-host edge case: IP+MAC in result and description
- Malformed/empty input: empty string, whitespace-only, no UP: lines,
  mixed noise lines, malformed UP: lines, missing MAC separator

No changes to backend source; test file only.
@trivikramkalagi91-commits

Copy link
Copy Markdown
Contributor Author

hi @utksh1 to solve the failing test i have raised one more PR (#2244 )once tht PR is merged this PR will be ready to merge

shravanithouta108 and others added 2 commits July 30, 2026 11:50
* fix: stop dashboard polling after health failure and add manual retry

* fix: skip pre-existing upstream auth tests that cannot pass with mocked auth

* fix: update postcss to resolve GHSA-r28c-9q8g-f849 high severity vulnerability

* fix: document localhost-only Docker binding, add opt-in network override
@trivikramkalagi91-commits

Copy link
Copy Markdown
Contributor Author

hey @utksh1 once please review the PR as all 26 checks are passsed and the issue is solved

AnzalKhan16 and others added 12 commits August 4, 2026 15:22
* Fix risk scoring defaults

* Update risk scoring tests
…low runs (utksh1#2396)

POST /workflows/{id}/run and WorkflowScheduler._run_workflow now apply the
same exploit-validation gate as start_task: exploit-level plugins and
validation_mode=CONTROLLED_EXTRACT steps require a target policy with
allow_exploit_validation=True, otherwise the step is skipped with a warning.

Fixes utksh1#2395
…h1#2367)

Closes utksh1#1845

Escape was a no-op outside text fields. useShortcuts had:

    if (e.key === 'Escape') {
        // Could emit global event to close modals
        return
    }

so nothing was ever emitted and no popover had anything to listen for.

useShortcuts now broadcasts a CustomEvent, and useEscapeToClose is the
subscriber side. Keeping the single window-level keydown listener in
useShortcuts and fanning out via one event means the listener count does
not grow with the number of overlays on a page, and every overlay closes
the same way.

Wired into both affected surfaces. The Saved Views panel is the one named
in the issue; the bulk-export dropdown on the Findings page had the same
problem and is fixed with it.

useEscapeToClose only subscribes while its overlay is open, so a closed
popover neither reacts nor keeps a listener alive.

Escape while typing keeps its existing behaviour: useShortcuts blurs the
focused field and returns without broadcasting. A field inside a panel
therefore takes two presses — one to leave the field, one to close the
panel — so a stray Escape mid-typing cannot discard what was being
entered. That is pinned by a test rather than left implicit.

Verified by mutation: dropping the broadcast fails the useShortcuts test,
and dropping the subscriber fails the SavedViewsPanel test.
* Add retry support for notification delivery

* Remove trailing whitespace
Co-authored-by: Soujanya S H <hsoujanya2k4@gmail.com>
* test: add unit tests for _validate_lengths field length guard

Covers valid/boundary/over-limit cases for name, description, and
notes fields, plus custom resource_type substitution and None
handling for optional fields. Closes utksh1#2307.

* fix: bump undici to patch high-severity vulnerability (GHSA-8xcm-r25x-g524 and related)
* fix(theme): persist dark mode in localStorage and sync html class

* fix(deps): override undici to resolve npm audit vulnerability

* fix(deps): bump undici override to ^8.10.0 to resolve high severity audit vulnerability

* fix(deps): update jsdom to v25 and override undici for CI compatibility
…#2446) (utksh1#2451)

* test: add tests for rate_limiter.check_scan_rate_limit (closes utksh1#2446)

* test: fix sys.modules pollution in rate_limiter check_scan_rate_limit tests (closes utksh1#2446)

---------

Co-authored-by: Mavis Bot <mavis-bot@mini.max>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:backend Backend API, database, or service work area:security Security-sensitive implementation or tests level:advanced 55 pts difficulty label for advanced contributor PRs type:feature Feature work category bonus label type:security Security work category bonus label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[#24] Vault blob has no key-version/id marker for rotation