This document analyzes the security posture of the Stellar-Micro-Donation-API, identifying potential attack vectors and providing actionable mitigations to ensure the integrity of the donation process.
The following areas represent the primary entry points for potential threats:
- Public API Endpoints:
/donations,/wallets, and/stats. - Credential Handling: The ingestion and processing of
senderSecret. - Infrastructure: The connection between this API and the Stellar Horizon network.
- Log Management: Storage of request/response data that might contain sensitive fragments.
| Category | Threat Scenario | Impact |
|---|---|---|
| Spoofing | Attacker intercepts or guesses a senderSecret to impersonate a donor. |
Unauthorized drainage of XLM from user wallets. |
| Tampering | Man-in-the-Middle (MITM) modifies the recipient address in the request body. |
Donation funds are diverted to an attacker's wallet. |
| Repudiation | A user claims a donation was never authorized due to a lack of unique audit trails. | Inability to resolve financial disputes or verify ledger history. |
| Information Disclosure | Verbose error messages leak internal paths or partial secret keys. | Attacker gains insight into the server environment or crypto logic. |
| Denial of Service | Flooding the /donations endpoint to exhaust account sequence numbers. |
Service becomes unavailable for legitimate donors. |
| Elevation of Privilege | Bypassing rbacMiddleware to access administrative stats or private wallet data. |
Unauthorized access to sensitive financial reporting. |
- Client -> API: The "Danger Zone" where the
senderSecretis transmitted. - API -> Service: Internal logic where the Transaction Envelope is built.
- Service -> Horizon: The boundary where the signed transaction enters the public ledger.
- Current Risk: Handling raw secrets in the request body.
- Mitigation: Move toward SEP-10 (Stellar Web Authentication) or implement client-side signing (using Freighter or Albedo) so the API only receives a signed transaction, never the secret key.
- Current Risk: Network retries causing double-spending.
- Mitigation: Utilize the
requestIdas an Idempotency Key. Before submitting to Horizon, check the localDatabaseto see if a transaction with that ID has already been successfully processed.
- Current Risk:
logger.jsmay capture thesenderSecretin the request body. - Mitigation: Implement a filter in the logging middleware to redact any field named
secret,seed, orkey.
- Current Risk: Automated scripts exhausting resources.
- Mitigation: Implement
express-rate-limitspecifically on the/donationsand/walletsendpoints to prevent brute-force or DoS attempts.
- Current Risk: Leaking stack traces in production.
- Mitigation: Ensure
errorHandler.jsonly returns generic codes (e.g.,INTERNAL_ERROR) in production while logging the full trace internally alongside therequestId.
- Does this change log any sensitive data?
- Is input validation strictly enforced for Stellar addresses?
- Does the new endpoint respect established RBAC permissions?