Closed Bug 1956698 Opened 1 year ago Closed 1 year ago

[Mac] Copy as powershell (on curl) leads to code execution on mac

Categories

(DevTools :: Netmonitor, defect)

defect

Tracking

(firefox-esr115 wontfix, firefox-esr128138+ fixed, firefox136 wontfix, firefox137 wontfix, firefox138+ fixed, firefox139+ fixed)

RESOLVED FIXED
139 Branch
Tracking Status
firefox-esr115 --- wontfix
firefox-esr128 138+ fixed
firefox136 --- wontfix
firefox137 --- wontfix
firefox138 + fixed
firefox139 + fixed

People

(Reporter: ameenbasha111, Assigned: bomsy)

References

(Blocks 1 open bug, Regression)

Details

(4 keywords, Whiteboard: [client-bounty-form][adv-main138+][adv-esr128.10+])

Attachments

(3 files, 2 obsolete files)

HI team, Firefox latest on mac is vulnerable for code execution, which allows the attacker to trick the user with malicious request to copy as powershell and run it on mac leads to code execution

Note: HTTP method is vulnerable part of the resultant curl.

FYI: we can install the powershell in mac via homebrew (instead of moving to windows, i have used this to run powershell command on mac) - Same possible on directly running in windows powershell too

Fetch Command: (run it on console)
fetch('',{method: '||whoami||'});

Steps to reproduce

  1. run the above command in browser console (we can achieve this via html file itself)
  2. copy the request as powershell
  3. paste and run it on powershell
  4. you can see the output of whoami command

Note: Issue tested on latest version of firefox

I will attached the poc video for reference shortly

Flags: sec-bounty?
Component: Security → Netmonitor
Product: Firefox → DevTools

Where did you find a Mac version of Powershell to paste the command into?

Blocks: curl
Flags: needinfo?(ameenbasha111)

When I tried to paste the "copy as powershell" string into the standard Mac bash terminal, lines were executed immediately upon pasting—didn't even have to hit "enter". It didn't run the embedded whoami command and basically just returned a bunch of syntax errors, but it's quite believable someone could find the right combination to get something executed.

Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: needinfo?(hmanilla)
Keywords: regression
Regressed by: 1795595

(In reply to Daniel Veditz [:dveditz] from comment #2)

Where did you find a Mac version of Powershell to paste the command into?

Microsoft provides a documentation for this

Ref: https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-macos?view=powershell-7.5

I have installed using homebrew method

Flags: needinfo?(ameenbasha111)

Set release status flags based on info from the regressing bug 1795595

https://searchfox.org/mozilla-central/source/devtools/client/netmonitor/src/utils/powershell.js#89

I hope this is the vulnerable place which cause this issue, Similar to body, headers use escapeStr for method too

parameters.push(-Method ${method}); => parameters.push(-Method ${escapeStr(method)});

Assignee: nobody → hmanilla
Flags: needinfo?(hmanilla)

Set release status flags based on info from the regressing bug 1795595

Pushed by hmanilla@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/7c67a571c098 [devtools] Escape the method value r=devtools-reviewers,nchevobbe
Group: firefox-core-security → core-security-release
Status: NEW → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 139 Branch

The patch landed in nightly and beta is affected.
:bomsy, is this bug important enough to require an uplift?

  • If yes, please nominate the patch for beta approval.
  • If no, please set status-firefox138 to wontfix.

For more information, please visit BugBot documentation.

Flags: needinfo?(hmanilla)

Comment on attachment 9476034 [details]
Bug 1956698 - [devtools] Escape the method value r=#devtools

Beta/Release Uplift Approval Request

  • User impact if declined/Reason for urgency: Security issue with curl command for powershell on Mac
  • Is this code covered by automated tests?: Yes
  • Has the fix been verified in Nightly?: Yes
  • Needs manual test from QE?: No
  • If yes, steps to reproduce:
  • List of other uplifts needed: None
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): Small Javascript to escape HTTP Methods properly
  • String changes made/needed:
  • Is Android affected?: No
Flags: needinfo?(hmanilla)
Attachment #9476034 - Flags: approval-mozilla-beta?

Comment on attachment 9476034 [details]
Bug 1956698 - [devtools] Escape the method value r=#devtools

Approved for 138.0b5

Attachment #9476034 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
QA Whiteboard: [post-critsmash-triage]
Flags: qe-verify-
Flags: sec-bounty? → sec-bounty+

Please nominate this for ESR128 uplift also when you get a chance.

Flags: needinfo?(hmanilla)
Flags: in-testsuite+

Comment on attachment 9476034 [details]
Bug 1956698 - [devtools] Escape the method value r=#devtools

ESR Uplift Approval Request

  • If this is not a sec:{high,crit} bug, please state case for ESR consideration: This is a security bug
  • User impact if declined: Malicious code can be run on user machine
  • Fix Landed on Version: 139
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): Small JS fix to escape HTTP methods when generating a Curl command for porwershell
Flags: needinfo?(hmanilla)
Attachment #9476034 - Flags: approval-mozilla-esr128?

Comment on attachment 9476034 [details]
Bug 1956698 - [devtools] Escape the method value r=#devtools

Approved for 128.10esr

Attachment #9476034 - Flags: approval-mozilla-esr128? → approval-mozilla-esr128+
Whiteboard: [client-bounty-form] → [client-bounty-form][adv-main138+]
Whiteboard: [client-bounty-form][adv-main138+] → [client-bounty-form][adv-main138+][adv-esr128.10+]
Attached file advisory.txt (obsolete) —
Attached file advisory.txt (obsolete) —
Attachment #9480701 - Attachment is obsolete: true
Attached file advisory.txt
Attachment #9480705 - Attachment is obsolete: true
Group: core-security-release
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: