Cookie API

Desciption

Lvl: 1 Score: 15 Category: web

This API here has a strange behavior. The endpoint /api/v1/init produces cookies. Ok! The /api/v1/store endpoint likes to eat cookies. LOL. Can you make it like your cookie too?

Analysis

Sending get request to init doesn't give us any results, but if we look in header we can see that Cookie is being set which expires in ~1 second.

$API="http://pwnme.org:8888/api/v1"

➜ curl "$API/init"

➜ curl -sS -D - "$API/init"
HTTP/1.1 200 OK
Set-Cookie: session_token=cm9sZT11c2VyJmlkPW9vcXI0R0VCRThWWlByZDFBbk5SMmlIbFRvMDlOU2py; Expires=Sun, 02 Jul 2023 21:16:05 GMT; Secure 
Date: Sun, 02 Jul 2023 21:16:04 GMT # Request send time
Content-Length: 0

Cookie is in Base64 format and if we decode it we get raw cookie values.

[System.Text.Encoding]::UTF8.GetString(
    [System.Convert]::FromBase64String(
        "cm9sZT11c2VyJmlkPUxVRm1hdVdvaU5USUgwUnFEUjZTb2Fsbm0wRWMzV2tD"
    )
)
role=user&id=LUFmauWoiNTIH0RqDR6Soalnm0Ec3WkC

To solve the challenge we must be admin. To become admin we must forge new cookie by modifing the cookie we get and all in 1 second.

Solution

Process ==> Get Cookie -> Decode Base64 -> Become admin -> Encode Cookie -> curl /store -> Profit.

For the kicks I created powershell one liner.

Last updated