Console icon indicating copy to clipboard operation
Console copied to clipboard

[SAST][Medium] Permissive Cross-domain Policy

Open alan-null opened this issue 1 month ago • 0 comments

Not a regression

ace.js https://github.com/SitecorePowerShell/Console/blob/248a7bc4e34c9a50e3709130408c62a90bc39e6c/src/Spe/sitecore%20modules/PowerShell/Scripts/ace/ace.js#L1748


Location:

Path: Sitecore.PowerShell.Extensions-8.0-Beta-2-IAR/files/sitecore%20modules/PowerShell/Scripts/ace/ace.js, line 1748
Path: Sitecore.PowerShell.Extensions-8.0-Beta-2.scwdp/Content/Website/sitecore%20modules/PowerShell/Scripts/ace/ace.js, line 1748
Path: Sitecore.PowerShell.Extensions-8.0-Beta-2-IAR.scwdp/Content/Website/sitecore%20modules/PowerShell/Scripts/ace/ace.js, line 1748
Path: Sitecore.PowerShell.Extensions-8.0-Beta-2/files/sitecore%20modules/PowerShell/Scripts/ace/ace.js, line 1748

Proof:

Image

Info: Setting targetOrigin to "*" in postMessage may enable malicious parties to intercept the message. Consider using an exact target origin instead.

Resolution

Code is using  win.postMessage(messageName, "*");

❌ vulnerable

otherWindow.postMessage({ type: 'PAYLOAD', data }, "*");

✅ safe — compute and pin the exact origin

const targetUrl = new URL("https://app.partner.example:443/embed");
const targetOrigin = targetUrl.origin; // "https://app.partner.example"
otherWindow.postMessage({ type: 'PAYLOAD', data }, targetOrigin);
  • Replace every postMessage(..., "*") with a specific origin.
  • Derive TARGET_ORIGIN from a known URL (never from untrusted input).
  • Prefer structured objects ({type: "...", ...}) over raw strings.

alan-null avatar Nov 28 '25 09:11 alan-null