# Codegate 2022 Write Up

### Summary

The codegate was held from February 26th to 27th, but I did not even participate because I was not interested, and I only solved 3 web problems today for study.

### (Web) CAFE

The CAFE challenge is very similar to the easyxss challenge I made in 2021. I heard that there were many solvers at the time of the competition because the administrator account was exposed as unintent.

If you look at the filterHtml() function, you can see that only a, img, code, and iframe tags can be used. We need to trigger XSS, but only a tags and iframe tags. However, the ‘a’ tag should be clicked by the bot, but there is no click event in the bot, so I just used an iframe.

If you look at the iframe tag part, the hostname of the src attribute value of the iframe should always be youtube.com. That is, it must be a URL such as https://google.com or http://google.com. But we can put hostname in javascript scheme.

All parsers provided by python, java, and javascript separate protocols and hostnames based on ://. But javascript://google.com does not run javascript. However, if it is used like javascript://google.com/%0aalert(1), it is excluded from execution by parsing. We can use this to get flags.

I inserted the above tag and reported it, so I was able to get an administrator session, and I logged in using the session and read the flag.

### (Web) babyFirst

A vulnerability occurs in the lookupImg() function. If a memo is written in the same syntax as [https://pocas.kr], the lookupImg() function fetches the value inside [] with a regular expression and then verifies the protocol.

When the file scheme is passed, it is returned immediately.

However, if you look at the URL code, if the start of the url starts with url:, it is parsed by moving the starting point by 4. That is, if the value of url:file:///etc/passwd is passed, it moves by 4 and only file:///etc/passwd is interpreted.

And if you check the file scheme again, you can see that the matcher value is parsed using /^[a-z]+:/ regular expression. Since the parsing is based on the colon, if you just pass it as url:file:///etc/passwd, the character before the first colon is parsed, so the file scheme does not take place. Parse it. As a result, it successfully parses file:///etc/passwd.

So just pass it to [url:file///flag] and read the image.

### (Web) MyBlog

If you look at the doReadArticle() function, the Xpath Injection vulnerability occurs because the idx value is added as it is.

But if you look at the location of the flag, it is in catalina.properties. So I just can’t read it. However, while studying Xpath Injection in the past, I used the system-property() function. The function of this function is to return the system property identified by the argument value. So just use this to return the system property called flag and read it with substring().