Skip to content

[v2] Fix aws login writing a DPoP key that cannot be loaded back - #10898

Open
simethan wants to merge 1 commit into
aws:v2from
simethan:fix/login-unloadable-dpop-key-10879
Open

simethan wants to merge 1 commit into
aws:v2from
simethan:fix/login-unloadable-dpop-key-10879

Conversation

@simethan

Copy link
Copy Markdown

Issue #, if available: #10879

Description of changes:

aws login generates a P-256 DPoP key and stores its SEC1 export in the login cache. About 1 in 256 keys has a private scalar starting with a zero byte, which awscrt on Linux exports with a 31-byte privateKey; awscrt's own importer then refuses it, so every command after that login fails until the next login. Two CLI-side changes:

  • Validate the key at generation time: _generate_dpop_private_key() loads the SEC1 export back once and regenerates the key if it cannot be loaded, so a bad key never reaches the cache.
  • Report an unreadable cached key cleanly: _load_private_key caught only ValueError, but awscrt raises RuntimeError for an unparsable key, so the intended LoginTokenLoadError path was never taken. It now catches both.

Description of tests:

5 new regression tests (unparsable cached key → LoginTokenLoadError, both mocked and with a real 31-byte-scalar key; key regeneration on a bad export; LoginError after repeated failures; fetcher generates a loadable key). Full tests/unit/botocore/test_credentials.py + tests/unit/customizations/login/: 225 passed (220 on pristine code — the delta is the 5 new tests). ruff check and ruff format --check clean.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Generated by AI tools, and reviewed by Ethan Sim.

@simethan
simethan requested a review from a team as a code owner November 14, 2026 00:05

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.

1 participant