Skip to content

Filter String-keyed sensitive params from logs - #3515

Merged
ashishdhingra merged 3 commits into
version-3from
ashdhin/string-key-log-filter
Dec 3, 2026
Merged

ashishdhingra merged 3 commits into
version-3from
ashdhin/string-key-log-filter

Conversation

@ashishdhingra

Copy link
Copy Markdown
Contributor

This PR mirrors aws/aws-sdk-ruby-staging#113.

Important

Check the version before merging and releasing. This PR sets MINIMUM_CORE_VERSION and MINIMUM_CORE_VERSION_S3 in build_tools/services.rb to 3.274.0, the minor release the Feature changelog entry produces. If another core change lands first and this fix ships in a different version, update both constants to that version.

Problem

Aws::Log::ParamFilter checks parameter keys against the generated SENSITIVE lists, which hold Symbols. The SDK also accepts String member keys, so a sensitive member passed with a String key was not matched and was written to the request log unredacted. For example, with Cognito Identity get_id:

client.get_id(identity_pool_id: "us-east-1:pool", "logins" => { "accounts.google.com" => token })
# before: get_id(identity_pool_id:"us-east-1:pool",logins:{"accounts.google.com"=>"<token>"})
# after:  get_id(identity_pool_id:"us-east-1:pool",logins:"[FILTERED]")

Change

  • Compare keys as Symbols in filter_hash (structure members) and filter_map (map keys vs. the :filter option).
  • Normalize the :filter option to Symbols, so filter: ['password'] and filter: [:password] behave the same.
  • Output keys keep their original type.
  • Strings that are not validly encoded are compared as-is instead of being converted, since to_sym raises for them and they cannot match a member name.
  • Raise MINIMUM_CORE_VERSION and MINIMUM_CORE_VERSION_S3 to 3.274.0 so service gems built in the next release require a core with the fix. The changelog entry is a Feature to produce that minor release.

Compatibility

  • Hashes with no shape (document-typed members, and params for old service gems) now redact String keys that are on the global sensitive list, such as "body", "name" or "type", the same way Symbol keys already were.
  • Map keys are still checked only against the :filter option, never the global list.
  • filter_sensitive_params: false still turns off all filtering. Symbol-key behavior is unchanged.

Testing

  • New specs for String and mixed keys: plain types, old service types (global list), nested structures/lists/maps through a ShapeRef, :filter given as Symbols and as Strings against both key types, keys that are not validly encoded (including Structure#to_s), and a formatter end-to-end case.
  • param_filter_spec.rb, formatter_spec.rb and structure_spec.rb: 75 examples, 0 failures.
  • Full aws-sdk-core suite: no new failures compared with version-3.

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

ParamFilter compared parameter keys against the generated SENSITIVE
lists, which hold Symbols. The SDK accepts String member keys, so a
sensitive member passed as a String (e.g. "logins" for Cognito Identity)
was written to the request log unredacted.

Compare keys as Symbols in both the structure and map paths, and
normalize the :filter option the same way. Output keys keep their
original type.

Bump MINIMUM_CORE_VERSION and MINIMUM_CORE_VERSION_S3 to 3.274.0, the
release expected to ship this fix, so updated service gems require it.
String#to_sym raises EncodingError for a String that is not validly
encoded, so a map or document key like that made ParamFilter raise,
breaking request logging (after the request was sent) and
Structure#to_s. Such a key cannot match a member name, so compare it
as-is.
Bumping MINIMUM_CORE_VERSION to 3.274.0 needs a minor release of
aws-sdk-core. An Issue entry produces a patch release (3.273.1), so the
minimum core gem would not exist. Per the V3 versioning policy, any
MINIMUM_CORE_VERSION bump uses a Feature entry.
@sankettangade

Copy link
Copy Markdown
Contributor

Can we trigger a dry run before merging? Thanks

@ashishdhingra
ashishdhingra merged commit 6e36882 into version-3 Dec 3, 2026
35 of 36 checks passed
@ashishdhingra
ashishdhingra deleted the ashdhin/string-key-log-filter branch December 3, 2026 20:04
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.

3 participants