Skip to content

In-depth lesson · postMessage abuse

Typical fixes

Every point the postMessage abuse reports back under this heading, best-backed first, each with the reports it is seen in.

Back to the lesson 1 to 33 of 33
  1. Do not allow a message handler to read a session token.

    Seen in 23 reports
  2. Check the message origin against an exact whitelist rather than a substring, prefix or regex match.

    Seen in 3 reports
  3. Do not assign message data to innerHTML; encode or sanitise it.

    Seen in 2 reports
  4. Validate that a URL from a message uses an HTTP or HTTPS scheme before assigning it to location.

    Seen in 2 reports
  5. Resolve a pathname from a message and check it stays under the intended prefix.

    Seen in 2 reports
  6. Do not allow a message handler to read or write cookies.

    Seen in 2 reports
  7. Do not trust the referrer as the message origin.

    Seen in 1 report
  8. Do not trust messages from the opener without checking its origin.

    Seen in 1 report
  9. Validate the origin on every message, not only the first.

    Seen in 1 report
  10. Escape all properties of a payload object, including inherited and read-only ones.

    Seen in 1 report
  11. Reject invalid protocols in a path filter.

    Seen in 1 report
  12. Whitelist the target origin instead of accepting a user-supplied value.

    Seen in 1 report
  13. Do not pass attacker-controlled ajax parameters to jQuery.ajax.

    Seen in 1 report
  14. Do not allow a route action to set arbitrary model data rendered as HTML.

    Seen in 1 report
  15. Do not combine allow-same-origin with a custom protocol that allows path traversal.

    Seen in 1 report
  16. Do not allow a message handler to execute arbitrary calls on an analytics object.

    Seen in 1 report
  17. Do not allow a message handler to invoke arbitrary methods by name.

    Seen in 1 report
  18. Do not allow a message handler to load an arbitrary script file as an extension.

    Seen in 1 report
  19. Do not allow a message handler to inject CSS into the page.

    Seen in 1 report
  20. Do not allow a message handler to set a map label with HTML.

    Seen in 1 report
  21. Do not allow a message handler to set an avatar URL parameter consumed by a widget.

    Seen in 1 report
  22. Do not allow a modal initialise message with an empty source.

    Seen in 1 report
  23. Do not allow a pushState message with an invalid protocol.

    Seen in 1 report
  24. Do not allow a call-popup redirect to an attacker domain.

    Seen in 1 report
  25. Do not allow a WebSocket reconnect to leak a token.

    Seen in 1 report
  26. Do not allow a message handler to read files from a private repository.

    Seen in 1 report
  27. Do not allow a message handler to leak the current user directory path.

    Seen in 1 report
  28. Do not allow a message handler to read contact form data.

    Seen in 1 report
  29. Do not allow a message handler to read screenshots.

    Seen in 1 report
  30. Do not allow a message handler to read an OAuth code.

    Seen in 1 report
  31. Do not allow a message handler to read an OAuth access token.

    Seen in 1 report