Skip to content

fix: security preset cannot render placeholders; disruptive SCPs opt-in - #43

Merged
Robobc merged 1 commit into
mainfrom
fix/security-preset-compat
Aug 25, 2026
Merged

fix: security preset cannot render placeholders; disruptive SCPs opt-in#43
Robobc merged 1 commit into
mainfrom
fix/security-preset-compat

Conversation

@Robobc

@Robobc Robobc commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

What

Usability-review blocker 5: the enterprise security quick start was internally incompatible, two ways.

Placeholders validated. presets/security-focused.yaml shipped org_id: "o-REPLACEME" and the schema accepted any string — the placeholder rendered into IAM policies against an organization that does not exist.

The guardrails denied their own platform. terraform/org-guardrails defaulted enable_scp_memory_enforce_cmk and enable_gateway_scps to true, while the accelerator's default deployment creates Memory without a CMK and runs Cedar in LOG_ONLY where the SCP assumes ENFORCE. Following docs/SECURITY_CONTROLS.md as written could lock the platform out of its own APIs.

Fixes

  • SecurityConfig.org_id gains a validator: empty stays allowed (deploy.sh prompts), a non-empty value must match o-[a-z0-9]{10,32}, and anything containing REPLACE/EXAMPLE/CHANGEME is rejected with the command that finds the real id.
  • The preset ships org_id: "" with that guidance inline.
  • The two disruptive SCPs are now opt-in; their descriptions say why and what to enable first. The identity SCP stays default-on — it denies an API the accelerator never uses.
  • docs/SECURITY_CONTROLS.md gets an "Org SCP compatibility preflight" subsection: SCP → what the accelerator must have enabled first, with the explicit lock-out warning.
  • The parity gate exports a shaped ORG_ID for synth (env beats platform.yaml), since the memory stack hard-fails resource policies without one — the predicted failure was reproduced first, then fixed.

Verified

143 tests green (three new: valid id passes, o-REPLACEME rejected pointing at describe-organization, wrong-shape rejected); contract parity green across all 6 configs; terraform fmt -check clean; ruff and shellcheck clean.

…opt-in

Usability review blocker 5, two independent defects:

(a) presets/security-focused.yaml shipped org_id "o-REPLACEME" and the
schema accepted any string, so the placeholder validated and rendered
into IAM policies (aws:PrincipalOrgID) against a nonexistent org.
SecurityConfig.org_id now has a field_validator: empty stays allowed
(deploy.sh prompts), a non-empty value must match ^o-[a-z0-9]{10,32}$,
and REPLACE/EXAMPLE/CHANGEME (any case) are rejected with a pointer to
`aws organizations describe-organization --query Organization.Id`.
The preset ships org_id "" with the same pointer in a comment.

(b) terraform/org-guardrails defaulted enable_scp_memory_enforce_cmk
and enable_gateway_scps to true, but the accelerator's own gateway sets
no KMS key and the security-focused preset runs Cedar LOG_ONLY while
the SCP assumes ENFORCE - following SECURITY_CONTROLS.md as written
could make the project's guardrails deny the project's own platform.
Both now default false; descriptions and a new compatibility-preflight
subsection in docs/SECURITY_CONTROLS.md spell out what to enable first
(security stack KMS on every covered memory; Cedar ENFORCE + gateway
CMK) and that attaching them over a default deployment locks the
platform out.

Consequence handled: with org_id now empty and resource_policies on,
the memory stack raises at synth (confirmed by running the parity
check). check-contract.sh exports ORG_ID=o-paritycheck123 next to
CDK_DEFAULT_ACCOUNT - env beats platform.yaml, real deploys still
prompt.

Verified:
- .venv pytest tests/ -q: 143 passed
- ruff check + format --check on platform_config.py and its tests: clean
- PY=.venv/... check-contract.sh: all 6 configs PASS
  (security-focused synthesizes, 8 stacks)
- shellcheck --severity=warning scripts/check-contract.sh: clean
- terraform fmt -check terraform/org-guardrails: clean
@github-actions

Copy link
Copy Markdown

Commit: 2d9dd3d | Updated: 2026-08-25 13:16:39 UTC

Security Scan Results

Scanner S C H M L I Time Action Result Thresh
bandit 0 0 0 0 44 0 706ms 0 PASSED MED (g)
cdk-nag 0 0 0 0 0 0 5.8s 0 PASSED MED (g)
cfn-nag 0 0 0 0 0 0 86ms 0 PASSED MED (g)
checkov 0 0 0 0 0 0 4.1s 0 PASSED MED (g)
detect-secrets 0 0 0 0 0 0 285ms 0 PASSED MED (g)
grype 0 0 0 0 0 0 49.7s 0 PASSED MED (g)
npm-audit 0 0 0 0 0 0 135ms 0 PASSED MED (g)
opengrep 0 0 0 0 0 0 13.1s 0 PASSED MED (g)
semgrep 0 0 0 0 0 0 <1ms 0 MISSING MED (g)
syft 0 0 0 0 0 0 1.8s 0 PASSED MED (g)

@Robobc
Robobc merged commit 616dcbf into main Aug 25, 2026
10 of 11 checks passed
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