Repository navigation
fix(console): open the pages of principals named new, . or .. - #1573
hitesh96db wants to merge 4 commits into
Conversation
The console served the user, group and role create forms at
/accounts/{id}/users/new, /groups/new and /roles/new, and the router
gives that static segment priority over {name}, so the page of a
principal named `new` could not be opened. Move the forms to
/accounts/{id}/new-user, /new-group and /new-role.
A browser resolves `.` and `..` segments out of a URL before it sends
it, so no path can reach a principal with such a name, and the delete
form of an inline policy named `..` posted to the delete of the user,
group or role that held it. Refuse `.` and `..` as user, group, role
and inline policy names in the management API and the console.
Fixes #845
Signed-off-by: Hitesh Sharma <hts@amazon.com>
A policy named . or .. made before the API refused them rendered a delete form whose action a browser resolves to the delete of the user, group or role. The row now names the extenddb manage command. Also cover groups and roles and the raw management PUT in the tests, and add the name rule to the differences document. Signed-off-by: Hitesh Sharma <hts@amazon.com>
navareamol
left a comment
There was a problem hiding this comment.
I think the delete confirmation gets lost when this is merged with main. Main now has the Content-Security-Policy from #1325, which does not run inline event handlers, and that change replaced every onsubmit="return confirm(...)" with data-confirm="...". The new policy_delete_form in console/pages/mod.rs still writes onsubmit="return confirm('Delete policy {ep}?')". It does not show up as a conflict, but the three page files do conflict, and if you keep your side there the policy Delete button deletes with one click and no question. Could you write data-confirm in the helper and add a test that a policy row has data-confirm and no onsubmit?
The description counts do not match the file. It says 11 tests, that the first 9 fail on main, and that the 2 policy form tests were not run on main. The file has 15 test items. I ran it: 15 pass at your head and all 15 fail on main.
The description and the new row in differences-from-dynamodb.md say IAM accepts . and .. and names of 1 to 128 characters, 64 for roles. Did you measure that on real IAM? If not, could the row say it comes from the documented pattern, or be cut?
For the record, the red CodeQL check is alert 252 on role_pages.rs line 121, serde_json::from_str(&form.trust_policy). The same alert is open on main, so it is not from this change.
I checked a policy named new (its Delete form works), group members named add, new and remove (removal works), percent encoded dot segments as policy names (refused) and a name with script tags (escaped on the missing page). All fine.
I will approve once the branch is merged with main and the policy Delete form uses data-confirm.
Signed-off-by: Hitesh Sharma <hts@amazon.com>
The console CSP from #1325 does not run inline event handlers, so the onsubmit confirm in policy_delete_form deleted a policy on one click. Write data-confirm, as the other console forms do, and add a unit test and a pytest that the policy delete form has it and no onsubmit. Reword the name-rule row in differences-from-dynamodb.md: the . and .. claim comes from the documented IAM name pattern, not from a measurement on IAM. Signed-off-by: Hitesh Sharma <hts@amazon.com>
|
Thanks, all four addressed. Merge commit c5ca46e (origin/main merged, no rebase); fix commit ef979fd.
Results: |
LJMart11
left a comment
There was a problem hiding this comment.
Reviewed at ef979fd. 1 finding: 1 Important.
The change moves the console's create forms to new-user, new-group and new-role and makes the management API and console refuse . and .. as user, group, role and inline policy names, with a Delete-form fallback for existing dot-named policies. Confirmed: with is_valid_path_name reduced to is_valid_iam_name, principal_names_refuse_dot_segments and a_policy_named_a_dot_segment_has_no_delete_form fail. cargo test -p extenddb-server passed (532) under 1.94.0. origin/main equals the merge base, so the merged tree is the head.
- Important
tests/test_console_csp.py:98—tests/test_console_csp.pystill posts to/users/new,/groups/newand/roles/new, which now answer 405, so all 17 of its fixture-using tests error.
Required — outside the diff
tests/test_console_csp.py:98
Important
tests/test_console_csp.py:98-103 still creates the user, group and role by POSTing to /accounts/{a}/users/new, /groups/new and /roles/new. This PR moves those forms to new-user, new-group and new-role (console/mod.rs:109-110,126-127,142-143), and the other console test files were updated but this one was not. The fixture's first step asserts 303 and gets 405, so the whole class errors in setup and the CSP and data-confirm checks from #1325 no longer run.
Fix: change the three paths in steps (lines 98, 101, 103) to /new-user, /new-group, /new-role; no migration. The upgrade manual entry and the PR's test list should also name this file.
Evidence: extenddb-pytest --backend sqlite tests/test_console_csp.py on the head gave 1 passed, 17 errors; the first error is AssertionError: /accounts/611957989756/users/new: 405 (assert 405 == 303) at tests/test_console_csp.py:109. The PR body lists five updated console test files and this is not one of them. origin/main equals the merge base, so this is not base drift.
What
Two changes, so the console can open the page of every user, group and role the management API creates.
/console/accounts/{id}/users/new,/groups/newand/roles/newto/console/accounts/{id}/new-user,/new-groupand/new-role(crates/server/src/console/mod.rs, the form actions inuser_pages.rs,group_pages.rs,role_pages.rs, and the buttons inaccount_pages.rs). The router gives a static segment priority over{name}, so the old paths hid the page of a principal namednew. They now open that page.management::is_valid_path_nameisis_valid_iam_nameplus "not.or..". The create handlers for users, groups and roles, and the inline policy put, in both the management API and the console forms, use it instead ofis_valid_iam_name. The error message gains ", and not . or ..".permissions_boundary.rsstill usesis_valid_iam_name, because there the name only looks up a principal that already exists.Inline policy names are included because their names are dot segments in console URLs too. Measured on origin/main (b6c8595), SQLite: a raw
PUT /management/accounts/{id}/users/u/policy/..answers 204, and the user page then shows the delete formaction="/console/accounts/{id}/users/u/policies/../delete", which a browser resolves to/console/accounts/{id}/users/u/delete. That button deletes the user, not the policy. With this change the same PUT answers 400.The upgrade manual (
docs/manuals/07-upgrade-manual.md) has av1.2.0:entry under Behavior Changes by Release. It covers the moved form paths, the refused names, and what to do with a principal or policy that already has such a name.Why
Fixes #845. I took both options from the issue: moving the forms fixes
new, and refusing the names fixes.and.., which no path can reach from a browser. The IAM API reference documents the name pattern[\w+=,.@-]+(CreateUser, CreateRole), which does not exclude.or... I did not measure IAM's answer for these names; the docs row says so. Percent-encoding the name in links would not help:%2Eand%2E%2Eare dot segments too under the WHATWG URL standard, and browsers remove them as well.Existing principals and policies named
.or..are kept. On the page of a principal, the row of an existing inline policy named.or..shows theextenddb manage delete-<kind>-policycommand instead of a Delete form, since a browser would resolve that form's action to the delete of the principal.docs/differences-from-dynamodb.mdhas a row for the name rule.extenddb managesends the raw path, so it can still read and delete them, as the issue measured.Testing done
tests/test_console_reserved_names.py(18 test items): the page of a user, group and role namednewopens with its<h1>and the create form is atnew-{kind}(3); the management API answers 400 for a user, group and role named.and..(6); the management PUT and the console's add-policy form refuse.and..for each kind (6); the policy row's delete form of a user, group and role hasdata-confirm="Delete policy pol?"and noonsubmit(3).data-confirmtests on main.cargo build --no-default-features --features sqlite, bound to 127.0.0.1), merged with origin/main.tests/test_console_integration.py,test_console_iam_user_pages.py,test_console_account_scope.py,test_arn_condition_values.pyandtest_policy_variable_syntax.pyare updated to the new ones. On the same server: after the merge with main, the four console files (with the new one) give 166 passed. The console tests of the last two files were not re-run after the merge (they gave 5 passed before it).http.client), which answers 400. Unit testsa_policy_named_a_dot_segment_has_no_delete_formanda_policy_delete_form_confirms_through_data_confirm_not_onsubmitcover the page row; the delete form usesdata-confirm, as the console's Content-Security-Policy (fix(console): serve the pages under a Content-Security-Policy that runs no inline script #1325) runs no inline handlers.management::iam_name_tests::principal_names_refuse_dot_segments.cargo test -p extenddb-server: 531 passed.cargo fmt --all -- --checkis clean.cargo +1.97.0 clippy -p extenddb-server --all-targets -- -D warningsis clean.cargo test --workspace, the full Python suite, and the PostgreSQL, MongoDB and Cassandra backends. The change is in the server crate and does not touch storage.Checklist
cargo test --workspace)cargo fmt --check)cargo clippy -- -W clippy::pedantic)Storagetrait, auth model, on-diskformat, or public CLI surface, an RFC has been accepted or is linked
below. Otherwise, an ADR captures the decision (link below).
ADR / RFC: n/a
Breaking changes
new, or the answer for a missing name..or..with 400.By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache License 2.0 and I agree to the Developer Certificate of
Origin (DCO). See CONTRIBUTING.md for details.