Skip to content

Rust #325: refuse policy maps that are not JSON objects, like PHP #705 - #719

Merged
rmcdaniel merged 2 commits into
mainfrom
rust-325-policy-json
Oct 24, 2026
Merged

rmcdaniel merged 2 commits into
mainfrom
rust-325-policy-json

Conversation

@rmcdaniel

Copy link
Copy Markdown
Member

Ports PHP #705 to native (#325). Published PHP silently turned malformed admission-policy JSON into an empty policy, so a configured cap could disappear. Native had the same defect:

  • DW_TASK_QUEUE_ADMISSION_OVERRIDES and DW_NAMESPACE_ADMISSION_OVERRIDES accepted malformed JSON.
  • All five maps native refuses accepted null, [], booleans and numbers.
  • DW_EXTERNAL_PAYLOAD_NAMESPACE_OVERRIDES, which native honors, became an empty policy when malformed.

Change

The six maps PHP now reads with EnvAuditor::jsonObject follow the same rule in config_audit::json_object:

  • the value is either unset or raw text that decodes to a JSON object;
  • Laravel's env() conversions do not apply;
  • a set DW_* name wins over its legacy name even when the DW_* value is invalid;
  • the startup refusal names the variable, never the value.

Native still refuses a non-empty object for the five maps it has no policy for. The external payload quota now reads its overrides with the same decoder.

Reference

This follows PHP main f67f2816e (#705), not the published 2.11.1 image. Every valid configuration behaves the same under both. The only values now refused are ones published PHP silently discarded and the next PHP image refuses at boot. Native, shared, frozen and OpenAPI contract bytes outside rust/src/config_audit.rs and rust/src/runtime/external_config.rs are unchanged.

Verification

  • cargo check --locked --all-targets: clean.
  • cargo test --lib config_audit: 12/12 pass, including the new policy_maps_must_be_json_objects_like_php_705. It covers all six maps under both names, 17 invalid values, padded {}, DW-over-legacy precedence in both directions, and that the refusal never repeats the value.
  • The shipped Compose and Helm values still start.

Checkpoint: docs/rust-server-port-checkpoints/2026-10-23-policy-map-json.md.

The six admission, durable-limit and external-payload policy maps are
read like PHP's EnvAuditor::jsonObject: unset, or raw text that decodes
to a JSON object. Malformed JSON, null, lists and scalars now stop
startup instead of silently becoming an empty policy. A set DW_ name
wins over its legacy name even when invalid, and the refusal names the
variable without its value. The external payload quota reads its
overrides with the same decoder.
@rmcdaniel

Copy link
Copy Markdown
Member Author

Security focused source review at exact fe8269b: accepted in principle. The six policy maps now fail closed on malformed or non-object JSON, a set primary name cannot silently fall back to a valid legacy value, the startup audit runs before runtime construction, and refusals identify only the canonical/source variable names without echoing values. Valid empty objects and the one native-honored external-payload object remain accepted; the other five still refuse nonempty policies native cannot implement.

This matches PHP #705 at the requested syntax/shape boundary without expanding native policy behavior. Final acceptance still requires the exact-head normal checks and current-main integration; the next released-image parity remains coupled to the broader #673/#708 publication train. No native/shared/frozen scope expansion or publication disposition is implied.

@rmcdaniel

Copy link
Copy Markdown
Member Author

Pre-integration head fe8269b25 passed all 26 hosted checks, including all six Rust suites. This head, c800c792e9d3a1b2d065b74336f38bfde6bea0ee, cleanly merges main 0667ba79f (8 image, bootstrap and CI files from #711/#716; no Rust or fixture overlap). cargo check --all-targets passes. Fresh checks are queued; it merges after the Rust suites pass again on this head.

@sonarqubecloud

Copy link
Copy Markdown

@rmcdaniel

Copy link
Copy Markdown
Member Author

Included in train #723, at exact head 069270b4e6a920720243ff7779c483d2f51a67ba on main 960aa3051. This PR's earlier hosted results are preserved above. Its remaining runs on the pre-#707 head are cancelled to free runners, and it closes as merged through #723.

@rmcdaniel
rmcdaniel merged commit 4f5b5f4 into main Oct 24, 2026
19 of 27 checks passed
@rmcdaniel

Copy link
Copy Markdown
Member Author

Merged to main through train #729 (merge 6121960), which Security accepted at exact head 18c1b3a.

@rmcdaniel
rmcdaniel deleted the rust-325-policy-json branch October 24, 2026 13:24
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