Latest / CyberCode Academy / Course 38 - Web Security Known Web Attacks | Episode 3: RFD, Mutation XSS, and RPO
Transcript
- 0:00Speaker 1: So imagine you lock your front door, right, you turn
- 0:04Speaker 1: on your state of the art security alarm, and you
- 0:05Speaker 1: feel perfectly safe, right as you should exactly. But then
- 0:09Speaker 1: somebody walks up to the house, and the system itself
- 0:13Speaker 1: it just automatically disarms and hands that person the keys
- 0:17Speaker 1: entirely because it was programmed to be relentlessly like helpful.
- 0:21Speaker 2: Yeah, that's a wild thought, it is.
- 0:24Speaker 1: And well, welcome to today's deep dive, because that's exactly
- 0:27Speaker 1: what we're getting into. We are taking an educational journey
- 0:31Speaker 1: into I guess you could call it the dark arts
- 0:33Speaker 1: of web vulnerabilities.
- 0:35Speaker 2: I like that, the dark arts.
- 0:36Speaker 1: Yeah, we're basically going to break down three specific mind
- 0:39Speaker 1: bending cyber attacks step by step for you today, and it.
- 0:42Speaker 2: Is such a fascinating space to explore because I think,
- 0:46Speaker 2: you know, the industry just defaults to picturing cybersecurity. Is
- 0:49Speaker 2: this this brute force discipline? Oh? Totally like the movie Hacker,
- 0:53Speaker 2: typing furiously exactly.
- 0:55Speaker 1: Yeah, the mental model is always supercomputers hammering login portals
- 0:59Speaker 1: millions of times a second, or you know, buffer overflows,
- 1:02Speaker 1: just smashing through memory boundaries.
- 1:04Speaker 2: Okay, But modern exploitation, however, is heavily about weaponizing logic.
- 1:08Speaker 2: Like we are looking at how browsers, when they're just
- 1:11Speaker 2: executing standard procedures, just doing their job right, like parsing
- 1:15Speaker 2: dom fragments, handling relative paths, or rendering style sheets, how
- 1:18Speaker 2: they could be tricked into essentially cannibalizing their own security models.
- 1:22Speaker 1: Wow.
- 1:23Speaker 2: Attackers chain these tiny, seemingly harmless functional quirks together until
- 1:29Speaker 2: the trust boundaries just completely collapse.
- 1:32Speaker 1: So we are we're diving right into the deep end today,
- 1:35Speaker 1: and I want to kick things off with a sequence
- 1:37Speaker 1: that I think perfectly illustrates that chaining concept to RFD. Yes,
- 1:41Speaker 1: the reflected file download attack or RFD. I mean, it's
- 1:44Speaker 1: an elegant, if slightly terrifying method for completely hijacking a
- 1:49Speaker 1: user's web browser to exfiltrate secure session tokens.
- 1:52Speaker 2: It really is a masterclass in exploiting trust mismatches, you know,
- 1:55Speaker 2: between the server and the browser.
- 1:57Speaker 1: Okay, so break that down force. How does it start?
- 1:59Speaker 2: So to pull the an attacker requires three strict conditions
- 2:02Speaker 2: to align. First, you need an API end point that
- 2:05Speaker 2: reslik's user and put directly into the response body.
- 2:08Speaker 1: Okay, so the server just echoes back whatever you sent it.
- 2:11Speaker 2: Exactly second, the attacker must be able to spoof the
- 2:14Speaker 2: downloaded files extension within the URL.
- 2:17Speaker 1: Wait, but browsers have pretty strict rules for that, don't they.
- 2:20Speaker 2: They do have strict parsing rules for parameters, but attackers
- 2:23Speaker 2: bypass these using matrix parameters or semicolon quirks.
- 2:28Speaker 1: Ah the semicolon right.
- 2:30Speaker 2: If an attacker injects a semicolon followed by say setup
- 2:34Speaker 2: dot beat into the URL path. Browsers like Chrome or
- 2:38Speaker 2: Opera will often drop the parameters following the semicolon for
- 2:42Speaker 2: routing purposes.
- 2:42Speaker 1: But they keep it for the download name.
- 2:44Speaker 2: Yes, they retain them for the file naming dialogue.
- 2:47Speaker 1: Oh wow. So they basically force the browser to treat
- 2:50Speaker 1: dot bet as the actual file extension completely bypassing standard
- 2:54Speaker 1: validation precisely.
- 2:56Speaker 2: But the server still has to serve it properly, which
- 2:58Speaker 2: brings us to the third, which is the header's right.
- 3:01Speaker 2: The service response must include a content disposition attachment header,
- 3:06Speaker 2: but crucially, that header must be malformed or incomplete.
- 3:10Speaker 1: Meaning what exactly.
- 3:12Speaker 2: It cannot specify a file name because the fall name
- 3:14Speaker 2: directive is missing. The browser it falls back to the
- 3:18Speaker 2: URL path to name the download.
- 3:20Speaker 1: And it sees that smuggled setup dot bat from earlier exactly.
- 3:24Speaker 2: Yeah, and it just drops a bash file straight onto
- 3:26Speaker 2: the user's.
- 3:26Speaker 1: Disc Okay, but the payload still requires execution, right, I
- 3:30Speaker 1: mean a bat file just sitting in your downloads directory
- 3:32Speaker 1: doesn't magically compromise the system.
- 3:34Speaker 2: No, No, doesn't.
- 3:35Speaker 1: It's kind of like a vampire. Right. It can stand
- 3:37Speaker 1: on the porch all night, but it cannot cross the
- 3:39Speaker 1: threshold until you, the user, explicitly click run and invite
- 3:44Speaker 1: it in.
- 3:44Speaker 2: That is a great analogy. Yeah, that social engineering layer
- 3:48Speaker 2: is really the only friction point here. The attacker relies
- 3:51Speaker 2: on the user trusting the domain the file originated from.
- 3:54Speaker 1: Because it looks like it came from a legit site.
- 3:57Speaker 2: Right. But once execution happens, the real time technical magic
- 4:00Speaker 2: kicks in. The attacker has to craft a Windows command
- 4:03Speaker 2: string that survives being sandwiched inside the server's reflected JSON
- 4:08Speaker 2: or XML data.
- 4:09Speaker 1: How do they do that if it's surrounded by junk code.
- 4:11Speaker 2: They do this utilizing the double pipe operator the two
- 4:15Speaker 2: vertical lines in the Windows command line.
- 4:18Speaker 1: Ah the or operator. So they structure the payload so
- 4:21Speaker 1: the system tries to execute the server's garbage JSON first.
- 4:25Speaker 2: Which obviously throws an immediate syntax.
- 4:27Speaker 1: Air right, and then the double pipe catches that failure
- 4:30Speaker 1: and forcefully evaluates the second half, which is the actual
- 4:34Speaker 1: malicious command. It's like saying to the computer, hey, try
- 4:37Speaker 1: to open door A, but if it's locked, just bust
- 4:39Speaker 1: open door B.
- 4:40Speaker 2: Exactly that. Let's trace the execution flow the millisecond the
- 4:44Speaker 2: payload actually runs. The first command in the chain is
- 4:46Speaker 2: usually a taskkill. Okay, the script forcefully terminates all running
- 4:50Speaker 2: instances of the target browser, say Chrome.
- 4:53Speaker 1: Wait, they kill the browser entirely.
- 4:55Speaker 2: Why because you can't pass new command line flags to
- 4:58Speaker 2: a browser that has already acted running in memory. You
- 5:01Speaker 2: have to start it cold.
- 5:02Speaker 1: But hold on, a browser just vanishing from the screen
- 5:04Speaker 1: is going to look incredibly suspicious to the user, isn't it?
- 5:07Speaker 2: It would, But it's just a momentary flash.
- 5:09Speaker 1: Yeah.
- 5:09Speaker 2: Immediately after the taskkill, they pipe the output into an
- 5:13Speaker 2: intentional error state, like calling MD on an invalid path,
- 5:17Speaker 2: just to ensure the double pipe logic flows cleanly into
- 5:19Speaker 2: the final command, which is restarting the browser.
- 5:22Speaker 1: Okay, so they restart it, yes, But when.
- 5:25Speaker 2: The script restarts Chrome, it passes an aggressive set of
- 5:28Speaker 2: silent command line flags. It disables pop up blogging, but
- 5:32Speaker 2: the critical flag is disabled web security.
- 5:35Speaker 1: Oh wow, so they are completely nuking the same origin
- 5:38Speaker 1: policy hirely by launching Chrome with disabled web security. The
- 5:42Speaker 1: fundamental bedrock of browser isolation is just gone.
- 5:45Speaker 2: Yeah. A script running on a malicious domain suddenly has
- 5:48Speaker 2: free rein to read the domb or make authenticated requests
- 5:52Speaker 2: to literally any other domain the user is logged into.
- 5:55Speaker 2: That's terrifying, and the climax of the exploit happens completely
- 5:58Speaker 2: invisibly in the background. With SOP disabled. The script opens
- 6:03Speaker 2: a hidden tab pointing to the attacker server. Oh sneaky
- 6:06Speaker 2: very That page executes the script that simply reaches across
- 6:09Speaker 2: the browser environment, targeting say mail doc, Google dot com
- 6:13Speaker 2: or an internal corporate portal.
- 6:15Speaker 1: And it reads the secure authentication cookies directly.
- 6:18Speaker 2: Yep. And because web security is disabled, the browser doesn't
- 6:22Speaker 2: throw a core's error, it doesn't block an HTTP context
- 6:25Speaker 2: from reading a secure flagged HTTPS cookie.
- 6:28Speaker 1: It just hands over the session token like it's nothing.
- 6:31Speaker 2: The attacker server receives the session token and the compromise
- 6:34Speaker 2: is complete and all without a single password being guessed.
- 6:38Speaker 1: That sequence is brutal, but I mean it still requires
- 6:41Speaker 1: that human element right, Like you said, the user has
- 6:44Speaker 1: to double click the payload sure, which makes me look
- 6:46Speaker 1: at our next vulnerability mutation EXSS or MXSS a bit differently,
- 6:50Speaker 1: because with MXSS, the browser's own rendering engine acts as
- 6:54Speaker 1: the executioner and there's absolutely zero user interaction.
- 6:58Speaker 2: Yeah, MXSS is a brilliant exploitation of parsing algorithms. It
- 7:02Speaker 2: heavily plagued older browser architectures, notably Internet.
- 7:06Speaker 1: Explorer eight, though to be fair, modern frameworks still occasionally
- 7:10Speaker 1: regress into similar behaviors.
- 7:11Speaker 2: They absolutely do. This is a DOM based vulnerability where
- 7:14Speaker 2: the initial payload is delivered in a completely neutralized HDL encoded.
- 7:18Speaker 1: State, meaning the server actually does everything right. It sanitizes
- 7:22Speaker 1: the input.
- 7:23Speaker 2: Right, It converts the malicious script tags into harmless HTML
- 7:27Speaker 2: entities like the little ampersand lt for a less end sign.
- 7:31Speaker 1: So the payload is stored in the DOM as totally safe.
- 7:34Speaker 2: Text It is entirely inert, but the vulnerability triggers when
- 7:38Speaker 2: client side JavaScript interacts with that safe text house. If
- 7:42Speaker 2: a script targets a DOM node containing that encoded payload
- 7:46Speaker 2: and reads its inner HTML property, the browser doesn't just
- 7:49Speaker 2: hand back the literal string of text.
- 7:51Speaker 1: Wait right, because inner HTML is a getter that invokes
- 7:54Speaker 1: the browser's EAHTML fragment serialization algorithm.
- 7:57Speaker 2: Exactly, the browser attempts to re construct the markup.
- 8:01Speaker 1: It's kind of like putting a harmless caterpillar inside a box, right, yeah,
- 8:04Speaker 1: and the box magically mutates it into a poisonous butterfly
- 8:07Speaker 1: right before you open it.
- 8:09Speaker 2: Yeah. Or like shipping a disassembled weapon through customs.
- 8:11Speaker 1: Oh, that's a good one.
- 8:13Speaker 2: Every individual piece clears the X ray because it's just
- 8:15Speaker 2: inert metal. But the moment the shipment clears the border,
- 8:19Speaker 2: the customs facility itself automatically reassembles the weapon before handing
- 8:23Speaker 2: it to the recipient.
- 8:24Speaker 1: So the browser serialization logic tries to be overly forgiving here.
- 8:28Speaker 2: Yes, when it processes those HQML entities during the inner
- 8:31Speaker 2: HTML read, the internal engine actually decodes the text back
- 8:36Speaker 2: into raw, unescaped characters.
- 8:38Speaker 1: Oh, I see, the safe entities are mutated back into
- 8:41Speaker 1: active HTML brackets exactly.
- 8:43Speaker 2: So the data goes in safe, but reading it back
- 8:45Speaker 2: out triggers the parser to essentially forge a brand new
- 8:49Speaker 2: EXSS vulnerability out of thin air. That is wild the
- 8:52Speaker 2: moment the mutated string is processed or written back into
- 8:55Speaker 2: the dome. The malicious script executes instantly. The server sanitization
- 8:59Speaker 2: is entirely bypassed by the client's own rendering logic.
- 9:03Speaker 1: Wow, it really forces us to examine the architectural tradeoffs,
- 9:06Speaker 1: doesn't it, between a parser that strictly enforces syntax and
- 9:10Speaker 1: a parser designed to sort of guess and fix perceived
- 9:13Speaker 1: errors to keep the page from crashing.
- 9:14Speaker 2: And that fault tolerance is exactly what creates the surface
- 9:17Speaker 2: area the browser tries to guess what the developer intended.
- 9:20Speaker 1: Which honestly bridges perfectly into the mechanics of our final
- 9:23Speaker 1: attack today, our POXSS or relative path overwrite cross site scripting.
- 9:28Speaker 1: Oh yeah, because here we move from exploiting the HTML
- 9:32Speaker 1: parser to weaponizing the CSS parser, relying on that exact
- 9:37Speaker 1: same philosophy of fault tolerance.
- 9:39Speaker 2: Our POXSS is just a beautifully convoluted attack. It requires
- 9:44Speaker 2: three specific architectural choices to intersect.
- 9:47Speaker 1: Okay, lay them out for us.
- 9:48Speaker 2: You need a stored CSS injection vulnerability, a server utilizing
- 9:53Speaker 2: ur rewriting or routing, and the application has to be
- 9:56Speaker 2: referencing its style sheets via relative paths.
- 10:00Speaker 1: Let's clarify that last bit for you really quick. The
- 10:02Speaker 1: difference between an absolute URL and a relative one. Sure,
- 10:05Speaker 1: So absolute URL is the full exact web address. It's
- 10:08Speaker 1: like giving someone your full mailing address, including your country
- 10:11Speaker 1: and zip code. But a relative URL is just the
- 10:14Speaker 1: local file name like dot slash style dot css. It's
- 10:17Speaker 1: like just telling your roommate, oh, it's in the kitchen.
- 10:19Speaker 2: That's exactly it. And in this attack, the URL routing
- 10:23Speaker 2: is the lynchpin. Modern frameworks route slash dashboard slash and
- 10:26Speaker 2: slash dashboard to the exact same controller logic.
- 10:29Speaker 1: Because the server doesn't care about the trailings.
- 10:31Speaker 2: Right, but the client side browser absolutely does care. When
- 10:34Speaker 2: an attacker appends a rogue slash to the end of
- 10:37Speaker 2: a targeted URL, they fundamentally de sync the browser's path
- 10:41Speaker 2: context from the server's reality.
- 10:43Speaker 1: It's confused.
- 10:44Speaker 2: Very The browser parses that trailing slash and concludes it
- 10:49Speaker 2: has descended one directory deeper into the file system. Oh okay,
- 10:52Speaker 2: So when the dom requests that relative style sheet you know,
- 10:55Speaker 2: style dot cas, the browser appends that request to its
- 10:59Speaker 2: new fat bricaded directory.
- 11:00Speaker 1: Path, meaning it requests a file that doesn't actually exist exactly.
- 11:05Speaker 2: But because the server routes everything dynamically. It doesn't throw
- 11:08Speaker 2: a standard four A four aer.
- 11:09Speaker 1: It just catches the confused request and serves the default
- 11:13Speaker 1: HTML response back to the browser.
- 11:15Speaker 2: Right, so, the browser requested CSS, but it received an
- 11:18Speaker 2: HTML document.
- 11:19Speaker 1: Wait, wouldn't a strict parser just analyze the mime type,
- 11:23Speaker 1: see the HTML tags, throw a syntax error, and just
- 11:26Speaker 1: halt everything.
- 11:27Speaker 2: It should? But CSS parsers are historically designed to be
- 11:30Speaker 2: incredibly fault tolerant.
- 11:31Speaker 1: There's that helpfulness again.
- 11:33Speaker 2: Yep, they do this sort of blind scanning. The CSS
- 11:36Speaker 2: parser encounters the HTML document, completely ignores the doc type,
- 11:40Speaker 2: ignores the head tags, and just choos through the raw text,
- 11:44Speaker 2: searching for anything resembling a valid CSS selector.
- 11:47Speaker 1: So it filters out all the noise until it collides
- 11:49Speaker 1: with the attacker's injected payload.
- 11:51Speaker 2: You got it. Remember the first condition of this attack
- 11:54Speaker 2: was a stored CSS injection. The attacker managed to slip
- 11:58Speaker 2: a snippet of CSS into say, a profile bio or
- 12:02Speaker 2: a comment feel.
- 12:03Speaker 1: And the parser finally hits that snippet and executes it exactly.
- 12:07Speaker 1: But wait, I want to pause on the execution phase here,
- 12:09Speaker 1: because injecting arbitrary CSS allows you to, I don't know,
- 12:13Speaker 1: change the background color or maybe overlay a phishing form.
- 12:16Speaker 1: It doesn't inherently give you cross site scripting. Standard CSS
- 12:20Speaker 1: doesn't execute JavaScript logic, does it.
- 12:22Speaker 2: Well, it doesn't today, but older browsers, specifically the ie
- 12:26Speaker 2: Trident engine, implemented a proprietary CSS property called expression Oh no.
- 12:32Speaker 2: It was an architectural decision made before modern CSS features
- 12:35Speaker 2: like calc existed. Microsoft wanted developers to be able to
- 12:38Speaker 2: calculate element withs or positions dynamically, so.
- 12:42Speaker 1: They basically build a bridge between the styling language and
- 12:45Speaker 1: the JavaScript runtime.
- 12:46Speaker 2: They did you could literally write raw JavaScript logic inside
- 12:51Speaker 2: a CSS declaration.
- 12:52Speaker 1: That sounds like a terrible idea in hindsight.
- 12:54Speaker 2: It was the expression property evaluated the JavaScript within the
- 12:58Speaker 2: context of the cssb parser. So the attacker injects an
- 13:02Speaker 2: expression payload into their profile.
- 13:04Speaker 1: But normally the page renders as HTML. The payload is
- 13:07Speaker 1: treated as harmless text and absolutely nothing happens.
- 13:10Speaker 2: Right, But when the attacker forces the RPO by appending
- 13:13Speaker 2: that extra slash.
- 13:15Speaker 1: The browser requests the HTML document feeds it into the
- 13:18Speaker 1: CSS parser. The parser strips all the HTML, finds the
- 13:22Speaker 1: injected expression and the JavaScript evaluates exactly.
- 13:25Speaker 2: You get a full XSS execution purely by confusing the.
- 13:28Speaker 1: Filepaths, which highlights a massive historical misstep in separating concerns. Frankly,
- 13:34Speaker 1: I mean, blurring the lines between presentation logic and execution
- 13:37Speaker 1: logic just gave attackers a massive sandbox.
- 13:40Speaker 2: It really, did, you know?
- 13:41Speaker 1: When you look back at how rpoxss works, it's almost
- 13:43Speaker 1: comical in its frigility. Hatiman, Well, you need the server
- 13:47Speaker 1: to rewrite the URL seamlessly, You need a stored injection flaw,
- 13:50Speaker 1: and you need a relative path. Like if the developer
- 13:53Speaker 1: just hard codes an absolute URL for the style sheet,
- 13:56Speaker 1: the browser never looks in the wrong directory and the
- 13:59Speaker 1: entire house of cards collapses.
- 14:01Speaker 2: That's so true, and that is the defining characteristic of
- 14:04Speaker 2: modern exploitation. We rarely see a single catastrophic flaw anymore.
- 14:08Speaker 2: It's all about the chain always. The RFD attack required
- 14:12Speaker 2: manipulating URL parameters and exploiting incompleainte HTTP headers just to
- 14:16Speaker 2: get the payload onto the disc right. MXSS required exploiting
- 14:20Speaker 2: the specific helpful behavior of the inner HTML serialization algorithm.
- 14:25Speaker 1: And RPOXSS required decincxing the URL path to trick a
- 14:29Speaker 1: fault tolerant parser into executing a deprecated feature. It's crazy
- 14:33Speaker 1: because every single one of these relies on the system
- 14:35Speaker 1: operating exactly as it was programmed to. I mean, the
- 14:37Speaker 1: browser wasn't broken, it was just overly accommodating.
- 14:40Speaker 2: Yeah. I tried to fix the broken markup. It tried
- 14:42Speaker 2: to render the malform CSS, it tried to parse the
- 14:45Speaker 2: complex URL.
- 14:46Speaker 1: The security boundaries failed because the parsers prioritize usability over
- 14:50Speaker 1: strict adherence to specifications.
- 14:52Speaker 2: We see this constant tension in software design. When you
- 14:56Speaker 2: build systems that try to automatically format data or or
- 15:00Speaker 2: quietly recover from syntax errors, you inevitably introduce dark corners
- 15:04Speaker 2: where logic can be manipulated.
- 15:06Speaker 1: So before we wrap up today, a quick review question
- 15:08Speaker 1: for you to test what you've learned. Can you recall
- 15:11Speaker 1: the three specific conditions required to pull off a relative
- 15:14Speaker 1: path override attack? Think about how the server handles URLs,
- 15:18Speaker 1: what kind of injection is needed, and how the style
- 15:21Speaker 1: sheet path is written.
- 15:23Speaker 2: It's a good exercise to walk through mentally, because we
- 15:26Speaker 2: spend a lot of time analyzing the quirks of legacy
- 15:29Speaker 2: architectures today. Things like CSS expressions or IE eight's dom behavior. Right,
- 15:33Speaker 2: but browser engines haven't stopped evolving, and they certainly haven't
- 15:36Speaker 2: stopped trying to be helpful.
- 15:37Speaker 1: Oh definitely not.
- 15:38Speaker 2: Think about the aggressive prefetching algorithms we have now, the
- 15:41Speaker 2: complexities of the shadow dom, or how frameworks aggressively hydrate
- 15:45Speaker 2: client side state. I'd leave you with this to chew
- 15:48Speaker 2: on what helpful user friendly features in today's modern smart
- 15:52Speaker 2: browsers are secretly laying the groundwork for the next generation
- 15:55Speaker 2: of mutation attacks.
- 15:57Speaker 1: Because the tools change, but the underlying philosophy remains identical.
- 16:01Speaker 2: Precisely, whenever the system attempts to guess the developers intent,
- 16:05Speaker 2: an attacker will eventually figure out how to control that guess.
- 16:09Speaker 1: It's a sobering reminder we started by talking about a
- 16:12Speaker 1: security system that disarms itself because it's trying to be helpful,
- 16:15Speaker 1: and in our architectures, extreme fault tolerance is often just
- 16:18Speaker 1: another phrase for an expanded attack surface. So keep questioning
- 16:22Speaker 1: the logic, look closely at your parsers, and until next time,
- 16:25Speaker 1: keep diving deep.