Skip to content

fix(identity): validate section and setting names when saving profiles - #2932

Merged
hezelin-work merged 1 commit into
feature/OHIfrom
fix/identity-profile-save-validation
Oct 14, 2026
Merged

hezelin-work merged 1 commit into
feature/OHIfrom
fix/identity-profile-save-validation

Conversation

@hezelin-work

@hezelin-work hezelin-work commented Oct 14, 2026 •

Copy link
Copy Markdown

Problem

Profile updates accepted section and setting names that the identity server does not support.

Solution

Validate section and setting names before saving profiles.

Testing: added unit tests.

License

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

- Accept only the profile and sso-session settings that the store
  loads.
- Require section names that the AWS SDK reads back as the same
  section.
- Write each section header and setting on a single line.
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@hezelin-work
hezelin-work marked this pull request as ready for review October 14, 2026 15:39
@hezelin-work
hezelin-work requested a review from a team as a code owner October 14, 2026 15:39

@ashishrp-aws ashishrp-aws 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.

🤖 AI-assisted review at ea403fd.

Approving. Validating on save is the right place for this. Checking that the section name reads back as the same type and name, and isn't an Object.prototype member, closes the header-injection and prototype-key cases. assertSingleLine in the serializer is a good backstop, because it also covers comments carried over from the existing file. sectionNameRegex matches smithy's prefixKeyRegex name class. Since save() only writes the config file, where typed sections must match that class, "the SDK does not load such names" holds.

Non-blocking:

  • The settings allowlist is a client-visible behavior change beyond names. save() now rejects the whole request if it contains any setting other than region/sso_account_id/sso_role_name/sso_session (or the three sso_* session fields). Before, extra settings were written. I couldn't verify that no IDE client (VS, JetBrains, Eclipse, VS Code) sends something like output or credential_process through updateProfile. Please confirm that, and add a line to the PR description and changelog alongside the name change.
  • Setting [${name}] is not supported. echoes the raw client-supplied name into the error. Run it through the same control-character check, or truncate it, before echoing.
  • Nit: typeof section.name !== 'string' runs after the !section.name presence check, so a non-string truthy name still reaches the regex. That's harmless, but the ordering reads oddly.

@hezelin-work
hezelin-work merged commit 2aadf5f into feature/OHI Oct 14, 2026
5 checks passed
@hezelin-work
hezelin-work deleted the fix/identity-profile-save-validation branch October 14, 2026 23:31
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.

4 participants