Skill 2.3.4

Sanitize sensitive data

Key Concepts

Inputs should be validated and sanitised before use to prevent injection attacks: use parameterised queries for SQL, encode output for HTML, and validate request bodies with API Gateway models or your own schema checks. AWS WAF adds protection against common attacks such as SQL injection and cross-site scripting at API Gateway, CloudFront or the load balancer.

Outputs must also be sanitised: error messages returned to clients should not reveal stack traces, internal hostnames or data, and logs should never contain passwords, tokens or full card numbers. Strip sensitive fields before writing logs or sending data to analytics.