Skip to content

fix(messaging): stop returning secret provider credentials - #14875

Merged
HarshMN2345 merged 1 commit into
mainfrom
fix-smtp-host-and-provider-credentials
Oct 23, 2026
Merged

HarshMN2345 merged 1 commit into
mainfrom
fix-smtp-host-and-provider-credentials

Conversation

@HarshMN2345

Copy link
Copy Markdown
Member

What changed

  • The Provider response model drops secret credential values (apiKey, apiSecret, authKey, authToken, password, secretKey, serviceAccountJSON) before output. Identifiers like bundleId, teamId, keyId, region, host and username are still returned. The rule shape and default stay the same, so SDKs are unaffected.
  • The Messaging e2e suite now asserts that secretKey is not in create/update responses.

Details are tracked internally.

Testing

  • php -l on the touched files. The Messaging e2e suite runs in CI.

@luxor-code-review

luxor-code-review Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Review complete. 🟡 1 medium

💬 Inline comments (1)


This PR makes provider API responses hide secret credentials by unsetting known secret keys inside Provider::filter, matching the write-only promise now documented in the credentials schema rule. An e2e assertion in the Messaging base suite verifies redacted credentials on provider responses. The redaction is a denylist (unset loop) over hardcoded key names; one medium-severity finding recommends inverting it to an allowlist so unrecognized credential keys — such as the SES adapter's sessionToken — can never leak.

Files Change
src/Appwrite/Utopia/Response/Model/Provider.php Strips hardcoded secret credential keys from the response model's credentials payload.
tests/e2e/Services/Messaging/MessagingBase.php Adds e2e assertions that provider responses omit secret credentials.

Reviewed commit: 8c80efc

@ghost

ghost commented Oct 23, 2026 •

Copy link
Copy Markdown

🔵 Tier A · Mergeable after minor fixes

The implementation is straightforward, but the regression test does not cover most of the secret fields it promises to redact.

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.

Verdict New comments Fixed Still open
✅ Approved 1 0 0
Finding Where
🟡 Test redaction for the other secret credential fields tests/e2e/Services/Messaging/MessagingBase.php:1585
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
File Change
src/Appwrite/Utopia/Response/Model/Provider.php Redacts named secret credential fields from Provider model output.
tests/e2e/Services/Messaging/MessagingBase.php Asserts SES secretKey is omitted from create and update responses.

Reviewed 8c80efc · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Tier A · Looks good to merge. Summary

$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']);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions

Copy link
Copy Markdown

Security rules

No new WARNING or ERROR findings from security rules.

6 existing findings tracked in .semgrep/baseline.json
  • php.appwrite.guest-write-without-abuse-limit (3)
  • php.appwrite.secret-compare-timing (1)
  • php.appwrite.weak-secret-env-default (2)

Posted by Checks / Rules. Re-runs update this comment in place. Rule details and baseline: .semgrep/README.md.

@luxor-code-review luxor-code-review Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment on lines +91 to +96
if (\is_array($credentials)) {
foreach (['apiKey', 'apiSecret', 'authKey', 'authToken', 'password', 'secretKey', 'serviceAccountJSON'] as $secret) {
unset($credentials[$secret]);
}
$document->setAttribute('credentials', $credentials);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.

@github-actions

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix-smtp-host-and-provider-credentials (after).

Metric Before After Change
🚀 Requests/sec 196.38 185.31 🔴 -5.6%
⏱️ Latency P50 86.9 ms 94.82 ms 🔴 +9.1%
⏱️ Latency P95 203.43 ms 214.76 ms 🔴 +5.6%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 94.82 214.76 11,400 185.31 +11.32
Account 171.08 324.34 600 10.19 +3.79
TablesDB 90.78 168.08 6,200 102.15 +1.36
Storage 88.42 203.18 3,000 51.68 +16.78
Functions 132.14 261.78 1,600 28.37 -1.68

Top API waits (after)

API request Max wait (ms)
tablesdb.rows.create 498.46
account.name.update 463.51
storage.buckets.create 429.06
account.prefs.update 403.11
account.get 400.45

@HarshMN2345
HarshMN2345 merged commit c922170 into main Oct 23, 2026
72 checks passed
ChiragAgg5k added a commit that referenced this pull request Oct 24, 2026
…14875)

On 1.9.x the Provider response model had no filter, so one is added; non-secret identifiers stay readable with providers.read.

(cherry picked from commit c922170)
ChiragAgg5k added a commit that referenced this pull request Oct 24, 2026
…14875)

On 1.9.x the Provider response model had no filter, so one is added; non-secret identifiers stay readable with providers.read.

(cherry picked from commit c922170)
ChiragAgg5k added a commit that referenced this pull request Oct 24, 2026
…14875)

On 1.9.x the Provider response model had no filter, so one is added; non-secret identifiers stay readable with providers.read.

(cherry picked from commit c922170)
ChiragAgg5k added a commit that referenced this pull request Oct 24, 2026
…14875)

On 1.9.x the Provider response model had no filter, so one is added; non-secret identifiers stay readable with providers.read.

(cherry picked from commit c922170)
ChiragAgg5k added a commit that referenced this pull request Oct 24, 2026
…14875)

On 1.9.x the Provider response model had no filter, so one is added; non-secret identifiers stay readable with providers.read.

(cherry picked from commit c922170)
ChiragAgg5k added a commit that referenced this pull request Oct 24, 2026
…14875)

On 1.9.x the Provider response model had no filter, so one is added; non-secret identifiers stay readable with providers.read.

(cherry picked from commit c922170)
ChiragAgg5k added a commit that referenced this pull request Oct 24, 2026
…14875)

On 1.9.x the Provider response model had no filter, so one is added; non-secret identifiers stay readable with providers.read.

(cherry picked from commit c922170)
ChiragAgg5k added a commit that referenced this pull request Oct 24, 2026
…14875)

On 1.9.x the Provider response model had no filter, so one is added; non-secret identifiers stay readable with providers.read.

(cherry picked from commit c922170)
Tapraj-Pathak pushed a commit to Tapraj-Pathak/appwrite that referenced this pull request Oct 24, 2026
…vider-credentials

fix(messaging): stop returning secret provider credentials

(cherry picked from commit c922170)
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