Skip to content

fix(security): sanitize ApiException in secret retrieval path - #15

Open
spbsoluble wants to merge 1 commit into
feature/env-var-credential-overridesfrom
fix/sanitize-apiexception-secret-retrieval
Open

fix(security): sanitize ApiException in secret retrieval path#15
spbsoluble wants to merge 1 commit into
feature/env-var-credential-overridesfrom
fix/sanitize-apiexception-secret-retrieval

Conversation

@spbsoluble

Copy link
Copy Markdown
Collaborator

Summary

  • Fixes Sanitize ApiException in secret retrieval path to prevent token leakage #13: GetStaticSecret let a failed GetSecretValuesAsync call propagate its raw ApiException. The Akeyless SDK's ApiException.Message can echo back portions of the request, including the live auth token, and this exception was reaching Keyfactor Command's logs unsanitized (wrapped in AggregateException via GetPassword's .Result).
  • Adds a catch (ApiException ex) block in GetStaticSecret (akeyless-pam/AkeylessPam.cs) that logs only ex.ErrorCode (HTTP status) and the secret name, then throws a sanitized InvalidSecretConfigurationException — mirroring the existing pattern in InitClient.
  • Adds a unit test asserting the sanitized exception message does not contain the raw SDK exception content.
  • Updates CHANGELOG.md, docsource/testing.md, and tests/AkeylessPam.Unit.Tests/README.md to keep the test matrix in sync.

Opened against feature/env-var-credential-overrides (PR #11) per request, since that's the currently open change to AkeylessPam.cs and this fix should land before/alongside it rather than against main.

Test plan

  • dotnet build akeyless-pam/akeyless-pam.csproj -c Release — succeeds
  • dotnet test tests/AkeylessPam.Unit.Tests/ — 63/63 passing (1 new test)

GetStaticSecret let a failed GetSecretValuesAsync call propagate its raw
ApiException, whose SDK-generated Message can echo back request content
including the live auth token, into Command's logs via the wrapping
AggregateException. Catch it and rethrow a sanitized
InvalidSecretConfigurationException, matching the existing pattern in
InitClient.

Closes #13
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