Scenario is this:
Parent.com can have a ‘html only’ file
and it has iframe with Iframe.com (php that i have full \controll ).
Question is this:
How can i check if iframe.com is loaded only by parent and cant be iframed by other domains
EDIT: Some solution suggest checking Referrer but this can be spoofed.
refereris as close as you can get before getting into really complicated territory.While it can be spoofed, it can only be spoofed by the client. A third party website couldn’t make the client spoof it.
That said,
refereris optional. Browsers don’t have to send it, and they tend not to under quite a lot of circumstances (such as when the referring document was served over HTTPS).The following might work…
This will generate false negatives when the browser doesn’t have a consistent ip address (such as when behind a group of proxy servers, which I seem to recall is quite common in cellular broadband), so I wouldn’t recommend it.