Skip to content

fix(console): open the pages of principals named new, . or .. - #1573

Open
hitesh96db wants to merge 4 commits into
mainfrom
fix/845-reserved-names
Open

hitesh96db wants to merge 4 commits into
mainfrom
fix/845-reserved-names

Conversation

@hitesh96db

@hitesh96db hitesh96db commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

What

Two changes, so the console can open the page of every user, group and role the management API creates.

  • The forms that create a user, a group and a role move from /console/accounts/{id}/users/new, /groups/new and /roles/new to /console/accounts/{id}/new-user, /new-group and /new-role (crates/server/src/console/mod.rs, the form actions in user_pages.rs, group_pages.rs, role_pages.rs, and the buttons in account_pages.rs). The router gives a static segment priority over {name}, so the old paths hid the page of a principal named new. They now open that page.
  • A new management::is_valid_path_name is is_valid_iam_name plus "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 of is_valid_iam_name. The error message gains ", and not . or ..". permissions_boundary.rs still uses is_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 form action="/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 a v1.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: %2E and %2E%2E are 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 the extenddb manage delete-<kind>-policy command instead of a Delete form, since a browser would resolve that form's action to the delete of the principal. docs/differences-from-dynamodb.md has a row for the name rule. extenddb manage sends the raw path, so it can still read and delete them, as the issue measured.

Testing done

  • New tests/test_console_reserved_names.py (18 test items): the page of a user, group and role named new opens with its <h1> and the create form is at new-{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 has data-confirm="Delete policy pol?" and no onsubmit (3).
    • On origin/main (b6c8595) the first 15 fail (measured by the reviewer: all 15 failed there, all 15 passed at the previous head). I did not run the 3 data-confirm tests on main.
    • With this change all 18 pass on a local SQLite server (cargo build --no-default-features --features sqlite, bound to 127.0.0.1), merged with origin/main.
  • The old form paths in tests/test_console_integration.py, test_console_iam_user_pages.py, test_console_account_scope.py, test_arn_condition_values.py and test_policy_variable_syntax.py are 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).
  • The policy tests now cover users, groups and roles, and send the management PUT with its path unnormalized (http.client), which answers 400. Unit tests a_policy_named_a_dot_segment_has_no_delete_form and a_policy_delete_form_confirms_through_data_confirm_not_onsubmit cover the page row; the delete form uses data-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.
  • New unit test management::iam_name_tests::principal_names_refuse_dot_segments. cargo test -p extenddb-server: 531 passed.
  • cargo fmt --all -- --check is clean.
  • cargo +1.97.0 clippy -p extenddb-server --all-targets -- -D warnings is clean.
  • Not run: 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

  • I have read CONTRIBUTING.md
  • All tests pass (cargo test --workspace)
  • Code is formatted (cargo fmt --check)
  • Clippy is clean (cargo clippy -- -W clippy::pedantic)
  • I have added or updated tests for new functionality
  • I have updated documentation if behavior changed
  • Breaking changes are noted below (if any)
  • If this changes the wire protocol, Storage trait, auth model, on-disk
    format, 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

  • The console's create-form URLs change, as listed above. Bookmarks or scripts that use the old paths now reach the page of a principal named new, or the answer for a missing name.
  • The management API and the console refuse new users, groups, roles and inline policies named . 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.

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 navareamol self-assigned this Dec 4, 2026

@navareamol navareamol left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Hitesh Sharma added 2 commits December 4, 2026 14:29
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>
@hitesh96db

Copy link
Copy Markdown
Contributor Author

Thanks, all four addressed. Merge commit c5ca46e (origin/main merged, no rebase); fix commit ef979fd.

  1. Delete confirmation: the conflicts in user_pages.rs, group_pages.rs and role_pages.rs keep main's CSP changes and this PR's policy_delete_form call. The helper now writes data-confirm="Delete policy {ep}?" (name escaped with html::escape, as main's other forms do; console.js reads it). No onsubmit= or inline on*= handler in the branch's crates/server/src. New unit test a_policy_delete_form_confirms_through_data_confirm_not_onsubmit, and pytest test_policy_delete_form_confirms_with_data_confirm for user, group and role.
  2. Counts: the file now has 18 test items (15 + 3 new). All 18 pass on a local SQLite server after the merge. I did not run the 3 new ones on main; your 15 failing on main stands. Description rewritten.
  3. IAM names: the claim was not measured. The description and the row in docs/differences-from-dynamodb.md now cite the IAM API reference pattern [\w+=,.@-]+ for CreateUser and CreateRole (which does not exclude . or ..) and say it was not measured. I dropped the 1-128 / 64 claim: the reference gives 64 for user and role names.
  4. CodeQL alert 252 (role_pages.rs serde_json::from_str(&form.trust_policy)) is open on main too. Left alone.

Results: cargo test -p extenddb-server 531 passed; cargo fmt --all -- --check clean; cargo +1.97.0 clippy -p extenddb-server --all-targets -- -D warnings clean; pytest test_console_reserved_names, test_console_integration, test_console_iam_user_pages, test_console_account_scope: 166 passed. Not run: test_console_csp.py, the full suite, other backends.

@LJMart11 LJMart11 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.py still posts to /users/new, /groups/new and /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.

This branch has not been deployed

No deployments
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.

Console: the page of a user, group or role named new, or of a user named . or .., cannot be opened

3 participants