Skip to content

docs: access policies + 4 scoped IAM users - #571

Merged
neuromechanist merged 8 commits into
devfrom
feature/docs-access-policies
May 22, 2026
Merged

neuromechanist merged 8 commits into
devfrom
feature/docs-access-policies

Conversation

@neuromechanist

Copy link
Copy Markdown
Contributor

Summary

New canonical doc at `docs/operations/access-policies.md` covering:

  1. Five operational principles that contributors and code follow:

    • Per-purpose IAM users, not a single mega-admin
    • Public reads MUST be unsigned (and signed only as fallback for private datasets)
    • Bucket-scoped, never account-scoped
    • Two-slot rotation, never down to zero
    • No long-lived keys in `~/.aws/credentials`
  2. IAM user catalog with full inline-policy JSON for the four
    scoped users that replace the previous single-admin key:

    • `nemar-worker-prod` — SCCN `nemar-api` Worker secret. S3 R/W on `nemar/` + `sts:GetFederationToken` scoped to `upload-`.
    • `nemar-worker-dev` — SCCN `nemar-api-dev` Worker secret. Same scope but restricted to `xx*` / `staging/` / `nm099999/` so destructive dev tests cannot touch live data.
    • `nemar-actions` — `nemarDatasets` org secret + `nemarOrg/nemar-cli` repo secret. S3 R/W on `nemar/*` with no STS (workflows never federate) and no PutObjectAcl (workflows don't change visibility).
    • `nemar-hallu-readonly` — SDSC Hallu cron local config. S3 ReadOnly. A leak cannot cause data loss.
  3. A shared permissions boundary (`nemar-bucket-boundary`) attached to all four users, capping their reach at the `nemar` bucket + the `upload-*` federated user pattern.

  4. A provisioning checklist for re-creating these users after an incident.

Motivation

On 2026-05-22 a compromised single-admin IAM key triggered AWS's automatic `AWSCompromisedKeyQuarantineV3` enforcement, which took down `data.nemar.org` for every dataset (every `getManifest` SigV4 GET started failing). The recovery hotfix (#570) restored read-only via unsigned-first / signed-fallback, but the underlying credential design needed to be rethought.

This doc captures the new design as a normative reference so the same single-point-of-failure cannot reappear.

Why a doc PR before the IAM rollout?

  • Codifies the design before any provisioning happens, so the actual users get created with the exact policies in the document (not a paraphrase).
  • Surfaces the "public reads MUST be unsigned" principle for review — that's an architectural rule that should be challenged before being baked into more code paths.
  • The provisioning itself is gated on AWS console root access (current admin user `yahya` is quarantined and cannot do IAM operations).

Out of scope (separate PRs)

  • Implementing the unsigned-public principle in other code paths (`buildRedirectUrl`, `generatePresignedGetUrl` for public datasets). Tracked separately.
  • Workers secret rotation policy, Cloudflare API token scoping, GitHub PAT/App scoping. The doc has a "Future scope" note; each gets its own follow-up.

Test plan

  • mkdocs builds cleanly (manual local check)
  • Each inline policy is valid IAM JSON syntax
  • Once provisioned in the AWS console, each user successfully performs its documented operations against the live bucket

@neuromechanist

Copy link
Copy Markdown
Contributor Author

Review findings addressed (commit on the updated branch):

Critical (both fixed):

  • (1) Added s3:GetBucketPolicy + s3:PutBucketPolicy to nemar-worker-prod (and nemar-worker-dev) BucketLevel statement; removed dead s3:PutObjectAcl. Doc now clarifies make-public mutates the bucket policy, not per-object ACLs.
  • (2) Principle 2 text updated to point at PR fix(s3): unsigned manifest+summary reads with signed fallback (hotfix) #570 (merged 0a8f510) where the unsigned-first pattern actually landed; the doc no longer claims behavior the code doesn't have.

Important (all fixed):

  • (3) Added s3:PutObjectRetention + s3:GetObjectRetention to both worker policies (Object Lock retention is distinct from legal hold).
  • (4) Split nemar-actions into nemar-actions-datasets (nemarDatasets org-level) and nemar-actions-cli (nemarOrg/nemar-cli repo-level) — different trust boundaries, independent rotation. Identical policy content.
  • (5) Boundary section now explicitly states it's a service-scope ceiling, not a read/write ceiling, with a note that nemar-hallu-readonly's read-only guarantee is enforced by its inline policy alone.

Suggestions (all addressed):

  • (A) Console-access verification (aws iam get-login-profile → NoSuchEntity) added to Appendix B.
  • (B) s3:GetObjectLegalHold + s3:GetObjectRetention added to nemar-hallu-readonly (inert reads).
  • (C) Object Lock actions added to nemar-worker-dev (e2e exercises lock step on nm099999).

Plus added: tagging (purpose, rotation-due) in Appendix B; boundary-before-inline ordering note in Appendix B.

User count is now 5 (was 4) after the actions split.

@github-actions

github-actions Bot commented May 22, 2026 •

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR571

Version: 0.8.27-PR571.727a5eb
Commit: 727a5eb


🤖 Updated on each push.

@neuromechanist

Copy link
Copy Markdown
Contributor Author

Live-validated against SCCN dev — nemar admin e2e-test --verbose now passes all 10 steps in 21s using the new IAM users.

Provisioned in AWS account 191754232783 (root login via aws CLI):

  • IAM group nemar-runtime containing all 5 users
  • Permissions boundary nemar-bucket-boundary (s3:* on nemar + sts:GetFederationToken on upload-*)
  • Users: nemar-worker-prod, nemar-worker-dev, nemar-actions-datasets, nemar-actions-cli, nemar-hallu-readonly
  • Tags: purpose=..., rotation-due=2026-08-22, managed-by=docs-access-policies
  • All five verified no console password (NoSuchEntity)

Keys deployed live (committed by the same value, two-slot rotation intact):

  • SCCN prod Worker (nemar-api): AWS_ACCESS_KEY_ID + AWS_SECRET_ACCESS_KEY
  • SCCN dev Worker (nemar-api-dev): same
  • nemarDatasets org-level (visibility=ALL): same
  • nemarOrg/nemar-cli repo secret: same
  • Hallu credentials file staged at /tmp/nemar-iam/hallu-credentials for manual scp

Live runtime fixes that surfaced during validation (also committed on this branch):

  • fix(sts): allow s3:CreateBucket on federation session (d65489d) — git-annex's initremote requires CreateBucket authorization on the federated session; added to both the federation policy in generateUploadPolicy() and the worker IAM user policies. Scoped to arn:aws:s3:::nemar only.
  • docs: StringLikeIfExists for dev ListBucket (HeadBucket fix) (048b877) — the dev policy's s3:ListBucket prefix condition broke s3:HeadBucket (which doesn't send s3:prefix). Switched to StringLikeIfExists so HeadBucket passes but prefix-scoped s3:ListObjectsV2 is still restricted. Doc now explains the trade-off in detail.

Permissions boundary turned out to be a service-scope ceiling, not a write-tier ceiling, as the prior review correctly called out. nemar-hallu-readonly's read-only guarantee remains enforced by its inline policy alone (no Put* / Delete* actions); the boundary's s3:* on the bucket is permissive enough to allow writes if someone added them to the inline policy. Documented in the boundary section.

Ready to merge.

@neuromechanist
neuromechanist merged commit 5a27e01 into dev May 22, 2026
9 checks passed
@neuromechanist
neuromechanist deleted the feature/docs-access-policies branch May 22, 2026 19:02
neuromechanist added a commit that referenced this pull request May 22, 2026
Flips the central-manifest-workflow flag from false→true under [env.dev.vars] only. Prod stays off. Full e2e on SCCN dev (10 steps, 21s) validated. Worker already deployed to SCCN dev; this commit makes the source of truth match the live state. Companion to #571 (access policies).

This branch was previously deployed

1 inactive deployment
npm — 727a5eb5 Deployed May 22, 2026 by neuromechanist via publish #1059
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant