Interview practice question
Securing postMessage communication with embedded iframes
Frontend Engineering · Async JavaScript and the Browser · Experienced
Your app communicates with an embedded payment iframe using postMessage. What security measures do you put in place?
What a strong answer covers
Your AI report card counts how many of these ideas you cover.
- Specify exact targetOrigin, never "*".
- Validate event.origin and event.source.
- Validate message schema.
- Minimal data exchanged.
- Sandbox/allow attributes; CSP frame-src.
Practise this topic
Start without signing up. Sign in free to get an AI report card on your answer.