Lucene search

K
huntrR4f7059A6B1FB4-EC9B-4CFA-AF1E-9CE304924829
HistoryMar 22, 2023 - 6:47 p.m.

Annotation tool: token forgery using jwt secret to claim super admin role

2023-03-2218:47:40
r4f705
www.huntr.dev
16
annotation tool
token forgery
jwt secret
super admin role
docker image
vulnerability
hard coded value
back-end code
security
bug bounty

EPSS

0.002

Percentile

53.2%

Although the annotator tool’s source code is not directly provided in the repository a docker image is provided. From there it is easy to get access to the source code by either extracting the docker tar image, which can be exported from docker itself, or connecting to the container with an interactive session and browsing the application files.

The vulnerability is based on the hard coded value of config.jwt.secret = Hm************tA which is located at config/config.production.js Using this value it is possible to create new jwt tokens that have the super_admin role and allow a low level user to make previously restricted actions.

To make the attack work the same method that was used for producing the original tokens must be applied for the forged ones. The easiest way to do this is by making some modification to the existing back-end code of the annotation tool. For example adding the lines provided below in the getSignedJWT function found in app/service/userService.js. Running a locally host version of the modded back-end and logging in with a simple user would also produce a new jwt token with the super_admin role. To use this new token simply read it from /tmp/test.txt inside the running container or host system and change the value of dpst-token found in local storage of your browser for the domain that was used to make the original login.

Proof of Concept

 const fs = require('fs');
    let x = this.app.jwt.sign(
      {
        id: 2,
        email: "[email protected]",
        role: "super_admin",
      },
      "Hm************tA"
    );

    fs.writeFile('/tmp/test.txt', x, err => {
      if (err) {
        console.error(err);
      }
    });

EPSS

0.002

Percentile

53.2%

Related for 9A6B1FB4-EC9B-4CFA-AF1E-9CE304924829