Browse Source

chore(core): Properly polynomial regex vulnerability

Michael Bromley 4 years ago
parent
commit
74250eaa12
1 changed files with 1 additions and 1 deletions
  1. 1 1
      packages/core/src/api/common/extract-session-token.ts

+ 1 - 1
packages/core/src/api/common/extract-session-token.ts

@@ -35,7 +35,7 @@ function getFromCookie(req: Request): string | undefined {
 function getFromHeader(req: Request): string | undefined {
 function getFromHeader(req: Request): string | undefined {
     const authHeader = req.get('Authorization');
     const authHeader = req.get('Authorization');
     if (authHeader) {
     if (authHeader) {
-        const matches = authHeader.match(/bearer\s(.+)$/i);
+        const matches = authHeader.trim().match(/^bearer\s(.+)$/i);
         if (matches) {
         if (matches) {
             return matches[1];
             return matches[1];
         }
         }