You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
… Pod
Key Improvements to post req create-checkout-session:
1. Input Validation with Joi: Ensures the incoming data (like donation, user, and letter) is valid before processing.
* donation: Must be a positive number.
* user: Must be a valid email.
* letter: Has a character limit to prevent overflows.
2. Origin Validation: Validates the origin header against a list of trusted domains. Requests from untrusted origins are rejected with a 403 Forbidden response. **This must be hardcoded, added in config files, or DB** (Line 55)
3. Error Handling: Catches validation errors and any unexpected errors to provide meaningful responses to the client while logging them for debugging.
4. Secure Logging: Avoids logging sensitive data. Logs only the origin if it’s valid, and logs warnings for untrusted origins.
Key Improvements to sessionSchema for least privilege:
1. Donation limit: The donation is capped at a reasonable value (max(10000)), reducing the risk of abuse from excessive amounts.
2. Scoped user object: We are limiting the user field to just an email address (instead of allowing any arbitrary data structure). This limits the amount of user data passed into the session.
3. Error messages: Explicit error messages are provided to make validation clearer for users without revealing too much information.
4. Letter size: The max length for the letter is reduced from 500 to 300 characters, limiting the potential impact of large data inputs.
5. Strict schema: By adding .unknown(false), we ensure that no extraneous data is accepted, enforcing stricter input control for least privilege.
In file: https://github.com/OpenSourceFellows/amplify/blob/main/server/routes/api/checkout.js
Copilot Prompts in quotes
The text was updated successfully, but these errors were encountered: