Why Lambda

Description

It looks like the AI hype has reached further than we thought. Help us shut down this poor alien attempt at Machine Learning, we found their website with a restricted admin dashboard can you exploit it?

Source

conf/nginx.conf

worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
daemon off;

events {
        worker_connections 768;
}

http {
        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
        ssl_prefer_server_ciphers on;

        access_log /dev/stdout;
        access_log /dev/stderr;

        server {
            listen 1337 default_server;
            listen [::]:1337 default_server;
            server_name _;
            location / {
                proxy_pass http://127.0.0.1:8080;
            }
            location /api/ {
                proxy_pass http://127.0.0.1:5000;
            }
        }
}

challege/backend/app.py

challege/backend/complaints.py

challege/backend/csrf.py

challege/backend/model.py

Solution

Why_Lambda.png

The application supports authentication, but it's just hardcoded to default values which are randomly generated 32 characters.

Why_Lambda-1.png

The heart of the application seems to be the model. We are allowed a "demo" version where we draw a number and model guesses the number.

Why_Lambda-2.png

The model is somewhat terrible at it's job, so we are allowed to submit complaints. Our complaint is saved into a json file, the bot visits /dashboard with Chromium, stays there for 10 seconds and leaves.

Vue on frontend takes the JSON data (complaints) and renders each item on /dashboard. The bot logins with admin credentials so XSS/CSRF seems likely.

Why_Lambda-3.png

Only CSRF would work, because HTTPONLY is set for cookies, meaning they cannot be transmitted over network, no cookies for us 😟

App does have CSRF protection, but from source we know it's easily bypassable with simple header 💀

We are also allowed to submit our own models, but only with "internal" API

Why_Lambda-4.png

The model is handled by tensorflow

Quick google shows RCE vulnerability: TensorFlow Remote Code Execution with Malicious Modelarrow-up-right

Ok, we have RCE... but how do we sneak it in? The obvious script tags wont work: Injecting <script>alert("1")</script> to OWASP Juice shop doesn't workarrow-up-right

No problem, we can load script via img onerror event:

Note: pastebin won't work, more info later.

Now we need a malicious CSRF script to do the heavy work.

First let's create the PoC. Phew... 9.8K is kinda a lot..... Ideal way to sneak it in would be to use Base64, but it's still to big. Luckily modern Javascript supports decompression: https://developer.mozilla.org/en-US/docs/Web/API/DecompressionStreamarrow-up-right

Much better.

Final PoC after playing around:

CSRF is possible from prediction value in compaint.

challenge/frontend/src/views/Dashboard.vue

Payload for prediction:

The pastebin version didn't work, because it needs Content-Type: text/javascript. Luckily pipedream platform supports different hooks for free! and we can take advantage of that. (I was lazy to open ngrok, lol)

Why_Lambda-5.png

New payload:

We create a script, give it a source of our payload, type=module because await/async kept complaining and lastly append the script to html. Bot should trigger the XSS in few seconds.

Why_Lambda-6.png
Why_Lambda-7.png
circle-check

Last updated