Open Redirect Affecting koa-remove-trailing-slashes package, versions <2.0.2


Severity

Recommended
0.0
medium
0
10

CVSS assessment made by Snyk's Security Team

    Threat Intelligence

    Exploit Maturity
    Proof of concept
    EPSS
    0.1% (41st percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications
  • Snyk ID SNYK-JS-KOAREMOVETRAILINGSLASHES-1085708
  • published 17 May 2021
  • disclosed 15 Mar 2021
  • credit apple502j

How to fix?

Upgrade koa-remove-trailing-slashes to version 2.0.2 or higher.

Overview

koa-remove-trailing-slashes is a Koa middleware that makes sure all requests does not have trailing slashes

Affected versions of this package are vulnerable to Open Redirect via the use of trailing double slashes in the URL when accessing the vulnerable endpoint (such as https://example.com//attacker.example/). The vulnerable code is in index.js::removeTrailingSlashes(), as the web server uses relative URLs instead of absolute URLs.

PoC

// Run the code below to set up a vulnerable server instance
// Then access http://localhost:3000///example.com

const Koa = require('koa'); const removeTrailingSlashes = require('koa-remove-trailing-slashes');

const app = new Koa();

app.use(removeTrailingSlashes());

app.use(ctx => { ctx.body = 'Hello World'; });

app.listen(3000);

References

CVSS Scores

version 3.1
Expand this section

Snyk

5.4 medium
  • Attack Vector (AV)
    Network
  • Attack Complexity (AC)
    Low
  • Privileges Required (PR)
    None
  • User Interaction (UI)
    Required
  • Scope (S)
    Unchanged
  • Confidentiality (C)
    Low
  • Integrity (I)
    Low
  • Availability (A)
    None
Expand this section

NVD

5.4 medium