rbac-authz
Skill3.4k starsChanged 8 months agoMITView on GitHub
Authorization in RedAmon: who may reach a project and at which level, what a non-owner may read of it, whose data a request touches (the tenant, the project's owner) against who acts (the person), and the static tests and switches every change meets. One policy lives in webapp/src/lib/authz/; a check written anywhere else is a second policy that the next sharing or permission change silently misses. Trigger: editing webapp/src/lib/authz/; adding a route.ts under webapp/src/app/api/ or changing its requirePermission / withPermission / requireLevel call; editing routeManifest.ts, scripts/gen-route-manifest.mjs or tests/fixtures/rbac_matrix/; editing a share, consent, transfer or revocation path; minting or reading a ticket, call token or run credential (webapp/src/lib/auth.ts, webapp/src/lib/plugins/callToken.ts, agentic/ws_ticket.py, agentic/machine_credential.py); editing webapp/src/app/api/graph-views/execute/injectProjectFilter.ts or graph_db/tenant_filter.py.
Trending
More talk lately.thin dataabout the whole repository
Who's talking about samugit83/redamon
- @yogsec.bsky.social“RedAmon is an open-source, self-hosted AI penetration testing framework. It maps your attack surface into a …”Bluesky · Oct 15, 2026 · 6 likes
- TensorBlock/awesome-mcp-servers“Add RedAmon MCP server”GitHub · Oct 7, 2026
- Jenqyang/Awesome-AI-Agents“Add RedAmon to Applications / Autonomous Agent Task Solver Projects”GitHub · Oct 7, 2026
- frangelbarrera/Awesome-Hacking-with-AI“Add RedAmon to Authorized Security Agents”GitHub · Oct 7, 2026
- skyvanguard/awesome-ai-pentesting“Add RedAmon to Autonomous AI Pentesting Agents”GitHub · Oct 7, 2026
The biggest 5 of 11 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 11
Talked about on GitHub and Bluesky (11 times).
On GitHub · 10
- Oct 7, 2026Add RedAmon MCP server — TensorBlock/awesome-mcp-servers0 reactions · 2 comments
- Oct 7, 2026Add RedAmon to Applications / Autonomous Agent Task Solver Projects — Jenqyang/Awesome-AI-Agents0 reactions · 1 comment
- Oct 7, 2026Add RedAmon to Authorized Security Agents — frangelbarrera/Awesome-Hacking-with-AI0 reactions · 1 comment
- Oct 7, 2026Add RedAmon to Autonomous AI Pentesting Agents — skyvanguard/awesome-ai-pentesting0 reactions
- Oct 1, 2026Add RedAmon to Tools — raphabot/awesome-cybersecurity-agentic-ai0 reactions
5 more on GitHub
- Oct 1, 2026Add RedAmon to Agents — kyrolabs/awesome-langchain0 reactions
- Oct 1, 2026Add RedAmon to Multi-paradigm Frameworks — enaqx/awesome-pentest0 reactions
- Oct 1, 2026Add RedAmon to AI Agentic Tools for Cybersecurity — The-Art-of-Hacking/h4cker0 reactions
- Oct 1, 2026Add RedAmon to Pentest & Red-Team Agents — scadastrangelove/awesome-ai-security-tools0 reactions · 1 comment
- Jun 6, 2026[Add] RedAmon (samugit83/redamon) — PyTorchKR/landscape0 reactions
On Bluesky · 1
- Oct 15, 2026RedAmon is an open-source, self-hosted AI penetration testing framework. It maps your attack surface into a Neo4j graph, then autonomously… — @yogsec.bsky.socialsays it tested it6 likes and reposts · 1 reply
In this repository22 other files it gives its agents.
- agentic/AGENTS.mdAGENTS.md
- AGENTS.mdAGENTS.md
- recon/AGENTS.mdAGENTS.md
- recon_orchestrator/AGENTS.mdAGENTS.md
- webapp/AGENTS.mdAGENTS.md
- add-community-skillSkill
- add-partial-reconSkill
- agentic-tool-integrationSkill
- agent-in-the-loopSkill
- builtin-agent-skillSkill
- graph-db-writesSkill
- llm-provider-integrationSkill
- mcp-server-toolsSkill
- orchestrator-container-spawnSkill
- plugin-platformSkill
- priority-board-triageSkill
- project-settings-cascadeSkill
- recon-ai-enrichmentSkill
- recon-tool-integrationSkill
- redamon-testingSkill
- supply-chain-scanSkill
- traffic-captureSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 151
A privileged change and its audit row commit together: Write the row with writeAuditTx(tx, entry) inside auditedTransaction(prisma, async …
≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
When to Use
- Adding a route, a permission, a share level or toggle, or any read a non-owner can reach.
- Changing who a request acts for: a WebSocket ticket, an MCP tool, a plugin call token, a scan's job credential, the agent's run config.
- Changing the filters that scope a caller's own Cypher.
The prohibition itself (no ownership or admin check outside webapp/src/lib/authz/) is a CRITICAL RULE in
webapp/AGENTS.md; this skill says which helper to call instead. Also
follow mcp-server-tools for an MCP tool, plugin-platform for a Gateway call,
graph-db-writes for a graph write (its MERGE key is the tenant), priority-board-triage for a
triage write, redamon-testing for the tests.
Critical Rules
NEVER compare ids or roles to decide access; call the helper for the case. authzStaticGuard.test.ts fails on a new
x.userId === user,role === 'admin',findFirst({ where: { id, userId } })orisAdminundersrc/app/apiandsrc/lib(it caught an inlinectx.token.userId !== ownerin the MCP triage start,b54b78fe).You need Call (all in webapp/src/lib/authz/)a route's permission, on a project or the instance requirePermission(request, perm, { projectId })orwithPermission(perm, handler, { projectId })(guards.ts)a second permission in the same request requireAlso(auth, perm)(guards.ts)a level beyond the permission's own (raw data is 'R*')requireLevel(auth, level)(guards.ts)a project outside a route (a lib, a job, a socket) projectAccess(subject, id, opts), thenmeetsLevel(access, level)(projectAccess.ts, levelTable.ts)a per-user row (preset, conversation author, token, user scope) ownsRow(subject, row.userId); a list:rowOwnerFilter(subject)(rowOwner.ts)the projects a person sees visibleProjectsWhere(subject)/visibleProjects(subject)(visibleProjects.ts)an administration permission of the signed-in person requireSessionPermission(session, perm); a route that changes the host reads the account again:accountHolds(userId, perm, { fresh: true })(adminPermission.ts)an account's own catalog under /api/users/[id]/requireSelfPermission(request, accountId, perm)(selfService.ts)- Under act-as, pass
{ actingAs: true }toprojectAccess. An admin acting as a collaborator reaches the share at Read and never more; without the option the acting admin gets the share's write level.can()passes it; a lib that callsprojectAccessitself must too. - NEVER let a level-less owner helper guard a write.
guardProject,requireProjectAccess,requireProjectScopedResource,requireProjectOwnerand the conversation helpers admit a read share, oversight and break-glass as readily as the owner. Only a permission atWor above on the same path stops them; levelLessHelpers.test.ts fails on a POST, PUT, PATCH or DELETE that reaches one without it. - Name the project in the guard whenever the route acts on one, as a literal
projectIdkey. Without itcan()makes a capability-only check: neither the person's access to the project nor its level is decided,auth.accessis null, and the manifest classes the call as a session guard. - ALWAYS update the route manifest in the same commit as the route. Run
node scripts/gen-route-manifest.mjsand commitrouteManifest.tswithrouteManifest.json; routePermissions.test.ts fails when a handler's first permission differs from its entry, or a handler asks none (add it toSESSION_ONLYwith the reason). The live matrix rows are generated from the manifest:node scripts/gen-rbac-matrix-rows.mjs --check. - A new permission goes in the registry with all its metadata
(permissions.ts: level,
crossTenant,gatesExisting,closesCrossTenantHole,mcpScopes;introducedInstaysUNRELEASED). Then regenerate the JSON copy withnpx vitest run src/lib/authz/builtinSets.test.ts -u; never editpermissionCatalog.jsonby hand. - A non-owner's read goes through the read views, never a hand-picked field list. A project
row:
projectReadView(row, auth.access)(projectReadView.ts) drops every column markedshare: secretin registry.yaml, so a new owner-only column is marked there. A graph answer:graphReadView(graph, access)(graphReadView.ts); any other output of chain nodes (export, versions, MCP):stripStepContent(nodes, access)(stepContent.ts). Raw files (traffic, workspace, scan outputs) needrequireLevel(auth, 'R*'). - A caller's own Cypher runs only through an allowlist. Saved views go through
injectProjectFilter.ts,
which refuses any character, call or node pattern it does not positively know; the agent, the
triage tools and the sandbox CLI go through
scope_queryin tenant_filter.py (inject, thenfind_unscoped_node_patternrefuses what it cannot prove scoped). Never add a denylist regex for one more shape: every shape Neo4j read and a denylist missed ran unscoped, a read of every project's graph. A new function or procedure joins the positive allowlist with a test of its cross-tenant case. Keep the tenant and the person apart in every hop. The tenant (the project's owner) keys graph, traffic, credential and model reads and writes; the person keys sessions, chats, the loop, quotas and the audit actor. Swapping them writes a collaborator's work into an empty graph of their own, or hands the owner's chats to the collaborator.
Hop Tenant Person webapp route auth.access.project.userIdauth.effective.userIdWebSocket ticket (auth.ts) ten, always writtensub;actunder act-asplugin call token (callToken.ts) tensubrun credential (machine_credential.py) tensub,actscan job credential (machineCredential.ts) tenon the job row, re-checked when it fires: actorScanRefusal(scanActor.ts)agent run (config.py) get_tenant_id(state, config)get_identifiers(state, config)MCP tool assertMcpProjectAccess(...).userIdctx.token.userIdA ticket or token without
tenreads assubonly so tokens minted before an update still verify; a new minting site always writes it (ws_ticket.pyticket_tenant).- A collaborator spends the owner's credentials only through a run toggle and the owner's
consent.
effectiveTogglesturns Run scans, Use AI agent and Exploitation & shells off without the consent row (ownerConsent.ts): never read a share's toggle columns yourself. A model-calling feature whose permission sits below Use AI agent asksownerCredentialRefusal(auth), then writes thecredits.usedrow first withrecordFeatureSpend(auth, feature)(ownerSpend.ts): no row, no spend. - Every loss of access calls
onAccessReducedonce its change has committed (revocation.ts): a share revoked, narrowed, left or expired, consent withdrawn, an account disabled, deleted or reset, a capability removed, a device session revoked. A ticket and a queued scan are checked only when they start, so without it the person's runs, sockets, queued scans, schedules and triage run go on. A new reason joinsProjectReductionorAccountReductionwith its entry inPLANS. - A start that writes a project asks who else is writing it. With sharing in force one
person writes a project at a time: while anyone writes it (a scan, an agent run, a triage run, a
mute-rule apply), another person's scan start or agent run is refused, 409
project_writer_busynaming who holds it (secondWriterRefusal/secondWriterResponse, projectWriters.ts;SECOND_WRITER_POLICY). The scan starts and the chat ticket ask it; a new start path asks the same function, never its own query. A socket outlives its ticket, so the agent asks again before every run it starts on the socket (a message, an approval, an answer, a tool confirmation, a resume:_refused_second_writerin websocket_api.py) through writer_check.py and the internal-key writer-check route, which reads the owner from the database. Keep the agent's answer map: 200{allowed: true}starts; 409project_writer_busyrefuses in the webapp's words; no answer or a 5xx is unverified (the owner,sub == ten, goes ahead with[rbac] project_writer_unverified, anyone else is refused); any other answer (400, 401, 404, a malformed body) refuses everyone, the owner included, because the browser picks the session id and an answer it can provoke must never let a run through. - One rule for a session id:
isWsSessionId(wsTicket.ts: 1-200 characters, no control or line-separator character). The ticket mint (400invalid_session_id) and the writer-check route use it, so a ticket the mint signed is never refused by the check. A client value written into an[rbac]log line goes throughlogValue(routeErrors.ts; the agent's_loggable). - A privileged change and its audit row commit together. Write the row with
writeAuditTx(tx, entry)insideauditedTransaction(prisma, async (tx) => ...)(audit.ts, auditForward.ts): a failed insert rolls the change back. A bareprisma.$transactionaround an audit write, or a directtx.auditLog.create, fails auditWriters.static.test.ts (its row would never be forwarded). The actor isauditActorOf(real, effectiveUserId)(auditActor.ts): the person signed in, the account acted as inonBehalfOfUserId.writeAudit(best effort, swallows a failed insert) is never the row of a privileged change. - A new audit action needs a label, and a reader of it a retention rule.
auditLabels.test.ts fails on an action without
an
AUDIT_ACTION_LABELSentry; auditRetention.test.ts fails on anaudit_logreader whose actions noKEPT_AUDIT_RULESrule keeps, since retention would delete the rows the code decides on. - A new feature sits behind its switch, and that switch's flags-off test proves nothing
changed. Read a switch only through
rbacFlags()(flags.ts). A new reader of the switch, or of a table it introduces, joins the readers list ofwebapp/src/lib/authz/<switch>.flags.off.test.ts(IDENTITY_READERS,PERMISSION_READERS,SHARING_STORAGE_READERS,WRITE_SWITCH_READERS,GOVERNANCE_READERS, ...), with a block appended (never a rewrite) saying what the off state does. A schema change stays additive: a column added to an existing table is nullable or has a default (schemaAdditive.test.ts). - A live matrix row whose answer depends on a switch carries its tag (
identity:,permissions:,sharing:,sharingwrite:,governance:withonoroff, read by rbac_matrix_live.sh), or it fails in the other state.sharing:is sharing in force (the switch and Root's policy); a route or field gated onRBAC_SHARING_ENABLEDitself, which exists with the switch on and the policy{}, takessharingswitch:(the S3a red: foursharing:offrows failed there). A write grant refused while write sharing is not in force answers per the write switch (write_sharing_offoff,above_max_levelon with Root's policy at Read):sharingwrite:offplussharingwriteswitch:. A row that raises a share to write with it in force acts onviewer_tmpand puts it back: the runner seeds once, so a raisedviewerfails every later Read-viewer row (the S5 red). - A project the caller cannot see and one that does not exist are the same 404. A 403 names
the permission (
forbiddenResponse,requireLevel) and goes only to someone who reaches the project below the level.
Pattern: the prologue of a project route
import { NextRequest, NextResponse } from 'next/server'
import { requireLevel, requirePermission } from '@/lib/authz/guards'
const { projectId } = await params
const auth = await requirePermission(request, 'recon:read', { projectId })
if (auth instanceof NextResponse) return auth
const raw = requireLevel(auth, 'R*') // only for raw data: files, traffic, step content
if (raw) return raw
const tenant = auth.access!.project.userId // the owner: key every graph, file and credential read on it
const person = auth.effective.userId // who acts: sessions, quotas, the audit actorsupply-chain download is a full route that starts this way.
Commands
cd webapp
node scripts/gen-route-manifest.mjs --check
node scripts/gen-rbac-matrix-rows.mjs --check
npx vitest run --no-file-parallelism src/lib/authz/authzStaticGuard.test.ts src/lib/authz/levelLessHelpers.test.ts \
src/lib/authz/routePermissions.test.ts src/lib/auditWriters.static.test.ts src/lib/authz/auditRetention.test.ts
npx vitest run --no-file-parallelism src/lib/authz/identity.flags.off.test.ts # one switch file at a time
cd .. && ./agentic/run_tests.sh tests/test_ticket_tenant_actor.py
./redamon.sh test unit # includes tests/test_tenant_filter_*.py (root-agent section)
bash tests/rbac_matrix_live.sh # live: needs the stack upResources
- README.SECURITY_POSTURE.md §7 (authorization and multi-tenancy), §9 (tickets), §16 (audit)
- README.DEV.md §8, "RBAC feature switches" - each switch, its requirement and roll-back
- Sharing-Projects.md, Identity-and-Access-Management.md - the levels and toggles as users see them
- Related skills:
mcp-server-tools,plugin-platform,graph-db-writes,priority-board-triage,redamon-testing
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

