Repository navigation
fix(messaging): stop returning secret provider credentials - #14875
Conversation
|
Review complete. 🟡 1 medium 💬 Inline comments (1)
This PR makes provider API responses hide secret credentials by unsetting known secret keys inside
Reviewed commit: 8c80efc |
🔵 Tier A · Mergeable after minor fixes
The Provider response model now removes configured secret fields from provider credentials while retaining non-secret identifiers. Messaging E2E assertions were updated to expect the SES secret key to be absent on create and update responses.
Fix with agent prompt### Issue 1
tests/e2e/Services/Messaging/MessagingBase.php:1585
**Test redaction for the other secret credential fields**
The create and update assertions only exercise SES `secretKey`, so an omission or typo for `apiKey`, `apiSecret`, `authKey`, `authToken`, `password`, or `serviceAccountJSON` would still let those credentials leak without failing this regression test.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.📂 Walkthrough · 2
Reviewed |
| $this->assertEquals(false, $response['body']['enabled']); | ||
| $this->assertEquals('my-access-key', $response['body']['credentials']['accessKey']); | ||
| $this->assertEquals('my-secret-key', $response['body']['credentials']['secretKey']); | ||
| $this->assertArrayNotHasKey('secretKey', $response['body']['credentials']); |
There was a problem hiding this comment.
Test redaction for the other secret credential fields
The create and update assertions only exercise SES secretKey, so an omission or typo for apiKey, apiSecret, authKey, authToken, password, or serviceAccountJSON would still let those credentials leak without failing this regression test.
Prompt To Fix With AI
This is a comment left during a code review.
Path: tests/e2e/Services/Messaging/MessagingBase.php
Line: 1585
Comment:
**Test redaction for the other secret credential fields**
The create and update assertions only exercise SES `secretKey`, so an omission or typo for `apiKey`, `apiSecret`, `authKey`, `authToken`, `password`, or `serviceAccountJSON` would still let those credentials leak without failing this regression test.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.🟡 Minor · testing · Reply if this doesn't apply.
Security rulesNo new WARNING or ERROR findings from security rules. 6 existing findings tracked in
|
There was a problem hiding this comment.
Adds credential redaction to the messaging Provider response model so provider secrets are stripped from API responses, with e2e coverage in the Messaging suite.
Key findings
- 🟡 Credential redaction denylist fails open — Provider.php:91
| if (\is_array($credentials)) { | ||
| foreach (['apiKey', 'apiSecret', 'authKey', 'authToken', 'password', 'secretKey', 'serviceAccountJSON'] as $secret) { | ||
| unset($credentials[$secret]); | ||
| } | ||
| $document->setAttribute('credentials', $credentials); | ||
| } |
There was a problem hiding this comment.
🟡 security · medium
Credential redaction denylist fails open
The new redaction in Provider::filter unsets a hardcoded list of seven secret keys, so any credential stored under an unlisted key is returned verbatim while the schema description promises secrets are never returned (src/Appwrite/Utopia/Response/Model/Provider.php:92-94).
This is already out of sync with the adapter layer: the SES adapter consumes credentials['sessionToken'] as a secret (src/Appwrite/Messaging/Provider.php:125), but sessionToken is not in the denylist, so any provider document that gains it — e.g. imported by migrations rather than the HTTP actions — leaks it to API clients.
Impact: silent exposure of provider secrets for any key the denylist does not name, breaking the write-only contract this PR documents.
📋 Prompt for AI Agents
In src/Appwrite/Utopia/Response/Model/Provider.php around lines 90-96, invert the redaction: instead of unsetting a hardcoded denylist of secret key names, build the filtered credentials from a positive allowlist of public identifier keys actually used by providers (bundleId, authKeyId, teamId, region, isEuRegion, domain, templateId, senderId, host, port, username, customerId, accountSid, accessKey, messagingServiceSid), keeping the legacy bundle -> bundleId mapping already handled above. Drop every unrecognized key so secrets the adapters consume — including sessionToken (src/Appwrite/Messaging/Provider.php:125) and any future key — are never returned, matching the write-only promise in the credentials rule description.
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
…vider-credentials fix(messaging): stop returning secret provider credentials (cherry picked from commit c922170)
What changed
Providerresponse model drops secret credential values (apiKey,apiSecret,authKey,authToken,password,secretKey,serviceAccountJSON) before output. Identifiers likebundleId,teamId,keyId,region,hostandusernameare still returned. The rule shape and default stay the same, so SDKs are unaffected.secretKeyis not in create/update responses.Details are tracked internally.
Testing
php -lon the touched files. The Messaging e2e suite runs in CI.