fix(auth): disable URL caching in FoundationClientEngine to prevent credentials being persisted to Cache.db - #4238
Merged
Conversation
The FoundationClientEngine is the base HTTP client used by the AWS SDK service clients (Cognito Identity / Identity Provider, etc.) for credential and token exchange. It previously used URLSession.shared, whose default configuration includes an on-disk URLCache. As a result, responses carrying Cognito tokens and AWS credentials were persisted to the app container's Cache.db, where they could be recovered by inspecting the device. Use a dedicated URLSession with urlCache = nil and a reloadIgnoringLocalCacheData policy so these responses are never written to disk. This mirrors the cache-disabling behavior already applied to the Hosted UI URLSession in AWSCognitoAuthPlugin+Configure.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4238 +/- ##
==========================================
- Coverage 66.85% 66.84% -0.02%
==========================================
Files 1151 1151
Lines 43869 43869
==========================================
- Hits 29329 29323 -6
- Misses 14540 14546 +6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
mattcreaser
approved these changes
Jun 26, 2026
harsh62
had a problem deploying
to
IntegrationTest
June 26, 2026 16:18 — with
GitHub Actions
Failure
thisisabhash
approved these changes
Jun 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue #
Description
A test found that user credentials and Cognito tokens were being persisted to
Cache.dbin the app container of iOS applications using this library.The root cause is in
FoundationClientEngine, the base HTTP client used by the AWS SDK Swift service clients (Cognito Identity / Identity Provider, etc.) throughPluginClientEngine.baseClientEngine(for:). It usedURLSession.shared, whose default configuration includes an on-diskURLCache. As a result, responses carrying tokens and AWS credentials were written toCache.db, where they could be recovered by inspecting the device.This fix uses a dedicated
URLSessionconfigured withurlCache = niland areloadIgnoringLocalCacheDatarequest cache policy, so these responses are never persisted to disk. This mirrors the cache-disabling behavior already applied to the Hosted UIURLSessioninAWSCognitoAuthPlugin+Configure.swift(makeURLSession()).The fix is applied at the library level and requires no app-side changes.
General Checklist
All integration tests passDocumentation update for the change if requiredGiven When Theninline code documentation and are named accordinglytestThing_condition_expectation()If breaking change, documentation/changelog update with migration instructionsBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.