Skip to content

Create tettst.html - #128

Open
maekuss wants to merge 1 commit into
mainfrom
maekuss-patch-34
Open

Create tettst.html#128
maekuss wants to merge 1 commit into
mainfrom
maekuss-patch-34

Conversation

@maekuss

@maekuss maekuss commented Aug 5, 2026

Copy link
Copy Markdown
Owner

No description provided.

@hacktron-app

hacktron-app Bot commented Aug 5, 2026

Copy link
Copy Markdown

Hacktron Security Check - Skipped

Reason: Billing required for Code Review seats

Add a payment method and start Code Review seat billing in organization billing settings

Go to: https://app.hacktron.ai/test-automations/billing

@hacktron-app-stg hacktron-app-stg Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file

Severity Count
HIGH 1

View full scan results

Comment thread tettst.html
Comment on lines +30 to +37
window.addEventListener('message', (event) => {
// Shows the origin but FAILS to validate it (critical bug)
document.getElementById('origin').textContent = 'Last message origin: ' + event.origin;

// Dangerous sink: direct innerHTML assignment of untrusted data
const incoming = typeof event.data === 'string' ? event.data : JSON.stringify(event.data);
document.getElementById('output').innerHTML = incoming;
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HIGH DOM-based Cross-Site Scripting (XSS) via Insecure postMessage Handler in tettst.html

The newly added file testerror/tettst.html introduces an insecure message event listener that does not validate the sender's origin (event.origin) and directly processes the message payload (event.data) using the dangerous innerHTML DOM sink.

An attacker hosting a malicious website can open this page in a window, tab, or iframe, and send a crafted postMessage containing malicious HTML/JavaScript. Because there is no origin check, the listener will accept the message and inject it directly into the DOM, executing arbitrary JavaScript in the context of the victim's session.

While this repository is designed as an educational demonstration of insecure postMessage handling, adding this new file introduces a new endpoint vulnerable to DOM-based Cross-Site Scripting (XSS).

Steps to Reproduce
  1. Open testerror/tettst.html in a web browser.
  2. Open the browser developer console on any other website (e.g., https://example.com).
  3. Execute the following JavaScript to open the vulnerable page and send a malicious payload:
    const win = window.open('path/to/testerror/tettst.html');
    setTimeout(() => {
      win.postMessage('<img src=x onerror="alert(document.domain)">', '*');
    }, 1000);
  4. Observe the alert dialog executing in the context of the vulnerable page.
Fix with AI

Open in Cursor Open in Claude

A security vulnerability was found by Hacktron.

File: tettst.html
Lines: 30-37
Severity: high

Vulnerability: DOM-based Cross-Site Scripting (XSS) via Insecure postMessage Handler in tettst.html

Description:
The newly added file `testerror/tettst.html` introduces an insecure `message` event listener that does not validate the sender's origin (`event.origin`) and directly processes the message payload (`event.data`) using the dangerous `innerHTML` DOM sink. 

An attacker hosting a malicious website can open this page in a window, tab, or iframe, and send a crafted `postMessage` containing malicious HTML/JavaScript. Because there is no origin check, the listener will accept the message and inject it directly into the DOM, executing arbitrary JavaScript in the context of the victim's session.

While this repository is designed as an educational demonstration of insecure `postMessage` handling, adding this new file introduces a new endpoint vulnerable to DOM-based Cross-Site Scripting (XSS).

Proof of Concept:
**Steps to Reproduce**

1. Open `testerror/tettst.html` in a web browser.
2. Open the browser developer console on any other website (e.g., `https://example.com`).
3. Execute the following JavaScript to open the vulnerable page and send a malicious payload:
   ```javascript
   const win = window.open('path/to/testerror/tettst.html');
   setTimeout(() => {
     win.postMessage('<img src=x onerror="alert(document.domain)">', '*');
   }, 1000);
   ```
4. Observe the alert dialog executing in the context of the vulnerable page.

Affected Code:
    window.addEventListener('message', (event) => {
      // Shows the origin but FAILS to validate it (critical bug)
      document.getElementById('origin').textContent = 'Last message origin: ' + event.origin;

      // Dangerous sink: direct innerHTML assignment of untrusted data
      const incoming = typeof event.data === 'string' ? event.data : JSON.stringify(event.data);
      document.getElementById('output').innerHTML = incoming;
    });

Acceptance criteria:
- Acceptance is defined by the **actual reported behavior**, not by tests passing.
- Reproduce the issue, or narrow the exact code path that produces it, *before* changing code. State what you confirmed.
- Fix the underlying cause. Mitigations that paper over the reported behavior do not count as a fix.
- Add a regression test that fails on the unpatched code and passes on the fix. If a regression test is genuinely impractical (e.g. race condition, infra-level issue), say so and explain why.
- Existing tests passing is **not** the bar. Do not declare done on tests-pass theatre.

Only change what is necessary to fix this vulnerability. Do not refactor adjacent code or modify unrelated files.

Triage: Reply !fp <reason> (false positive), !valid (confirmed), !accepted_risk <reason>, or !fixed (resolved). Any other reply is saved as a triage note.
Reason is optional but improves future scans — e.g. !fp internal endpoint, not user-facing.

View finding in Hacktron

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A fix for this finding has been opened: #129

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant