Skip to content

Pentest fixes and hardening#321

Merged
level09 merged 120 commits into
mainfrom
pentest-fixes
Jul 20, 2026
Merged

Pentest fixes and hardening#321
level09 merged 120 commits into
mainfrom
pentest-fixes

Conversation

@level09

@level09 level09 commented Apr 21, 2026

Copy link
Copy Markdown
Collaborator

Fixes for the 7ASec BAY-01 engagement, on top of baseline 8615ff11b. One commit per finding, tagged fix(BAY-01-NNN): so the retest maps fixes by git log --grep BAY-01 pentest-fixes.

42 of 43 fixed. Open: BAY-01-017 (release signing), a product decision, not a code gap.

Finding to commit

001 80f56b9bc   015 4f8b40e68   028 0cddfca22   039 aa7ecb076
002 d0f4581da   016 18059510d   029 bc467b9df   040 9bfca8af5
003 3ce769fe8   018 ce2afebcb   030 fa3069dcd   041 726d34582
004 4b66981d5   019 ee18f11ee   031 dc8e62fec   042 b186e1b96
005 597e7e6c1   020 f55f7a01c   032 adf941e8d   043 c0adefa7c
006 507bab008   021 f541199f7   033 5bbacd183
007 ecc4aa76f   022 85e7f540a   034 279b3c8f8
008 9800fbed6   023 0cba2461f   035 f1990806b
009 0614f8aad   024 09f3f60b5   036 5abe376ea
010 f34e6790c   025 4708fe422   037 9ee85af9f
011 dec0516ea   026 76f431fff   038 6f562d461
012 8b0c2d5c3   027 a5280d017
013 e4f26caac   014 ddabe8eaa

017 is unaddressed pending the signing decision. minisign keypair exists, public key pinned; manual sudo bayanat update stays as the fallback.

Partials worth flagging

  • 020: filename enumeration closed (opaque names). Per-item auth on /api/serve/inline/<filename> is a separate parent-binding change, deferred.
  • 028 issue 6: passwords are out of argv (in-container config file + REDISCLI_AUTH). Delivery stays via env vars because Compose can't mount env-sourced secrets into read_only containers.
  • 031: app DB role stripped of superuser/createdb/createrole/replication and CONNECT revoked from PUBLIC, but keeps table ownership because dynamic-fields runs ALTER TABLE at runtime.

Retest

Backend regression tests: uv run pytest tests/test_pentest_fixes.py. No frontend harness in this repo; 034 verified by review. Each commit message has root cause and where to verify. Fresh install recommended (005 changed the install flow: the installer now generates and prints the admin password once).

level09 added 30 commits April 18, 2026 00:06
Adds nav-bar chip that polls /admin/api/updates/available every 6h and
shows a confirm dialog to trigger an update. Adds polling progress dialog
that opens on update-started event and tracks /admin/api/updates/status
at 2s intervals until the run completes.
@apodacaduron

Copy link
Copy Markdown
Contributor

BAY-01-015 looks fixed.

I tested by changing the export ID in the URL/API to another user’s export. The server returned 403 Forbidden, so the export metadata is no longer exposed.

Minor note: 403 vs 404 can still hint that an export ID exists, but that is low impact and not the main issue.

Unrelated UX issues noticed while testing:

  • If an Admin changes their own role from Admin to Mod while on /admin/users/, they land on a raw Forbidden page with no way out. They have to manually change the URL to a valid path.
  • As a Mod, /admin/api/updates/available returns 403 and shows a “You do not have permission to view this resource” snackbar.

level09 added 2 commits June 19, 2026 13:01
Bulletin/Actor to_dict() embedded full media metadata (filename, etag,
title, OCR extraction text) in the medias array for any user who could
read the parent, even those blocked from the media endpoints by
_require_media_access. A non-Admin without can_access_media therefore
still received the data the direct endpoints deny them.

Gate the medias loop on a shared can_view_media() helper that mirrors
the _require_media_access policy (Admin or can_access_media) and trusts
CLI/Celery via has_request_context, matching check_history_access.
The single-OCR endpoint requires can_edit (assignment boundary) since
OCR writes an extraction, but /api/ocr/bulk scoped items only by
can_access (visibility), letting a non-Admin with can_access_media
OCR-mutate media they can read but are not assigned to edit.

Post-filter the resolved media ids by can_edit for non-Admins. The
query-level access filter can't express can_edit (needs the parent's
assignment + status), so it is done in Python; Admins skip the filter.
@apodacaduron

Copy link
Copy Markdown
Contributor

BAY-01-018 looks fixed for the main reported issue.

I tested a bulk Bulletin update as a Mod with:

  • Bulletin 12: accessible
  • Bulletin 11: restricted

Only Bulletin 12 was updated. Activity Monitor only showed Bulletin 12, and only Bulletin 12 got a new revision history entry.

Separate issue found while testing Incident bulk updates:
When using the assignRelated option, related Bulletins can get duplicate revision history entries.

Test:

  • Set chunk size to 1 for testing
  • Bulk updated 2 incidents with assignRelated=true
  • Incident 1 was related to Bulletin 12
  • Incident 2 was related to Bulletins 12, 11, and 10

Result:
Bulletin 12 received 3 new revision history entries from one bulk operation.

So the original restricted-ID logging issue seems fixed, but assignRelated can still create duplicate history entries for related Bulletins.

@apodacaduron

Copy link
Copy Markdown
Contributor

BAY-01-022 looks fixed for the normal Bulletin update API, but I found a remaining bulk-update edge case.

Test:

  • Bulletin 10 was assigned to a DA user.
  • Its status was set to Peer Review Assigned.
  • As the assigned DA user, a direct normal update returned 403: {"message": "Item is locked for peer review"}.
  • However, using a Mod account, the bulk update endpoint still allowed updating Bulletin 10 while it was in Peer Review Assigned.

So the normal edit path is protected, but bulk update can still mutate peer-review-locked Bulletins.

apodacaduron
apodacaduron previously approved these changes Jul 3, 2026
@level09
level09 changed the base branch from auto-update-simplified to main July 13, 2026 21:18
@level09
level09 dismissed apodacaduron’s stale review July 13, 2026 21:18

The base branch was changed.

…I, export all media with access filter, actor name fallback)
Comment thread tests/conftest.py Fixed
Comment thread enferno/tasks/maintenance.py Fixed
Comment thread tests/test_pentest_fixes.py Fixed
Comment thread tests/test_pentest_fixes.py Fixed
Comment thread tests/test_pentest_fixes.py Fixed
@level09
level09 merged commit 38fa944 into main Jul 20, 2026
11 checks passed
@level09
level09 deleted the pentest-fixes branch July 20, 2026 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants