Ts Unsafe Deserialization Untrusted Data
Description
Detects unsafe object deserialization vulnerabilities when using the node-serialize module in Express applications. When untrusted data is deserialized without proper validation, attackers can inject malicious serialized objects that execute arbitrary code during deserialization.
Detection Strategy
• The application imports both 'express' and 'node-serialize' modules
• Code contains deserialization function calls from the node-serialize module
• The deserialization operation processes untrusted/external data without proper validation
Vulnerable code example
import express from 'express';
import serialize from 'node-serialize';
const app = express();
app.use(express.json());
app.post('/api', (req, res) => {
const obj = serialize.unserialize(userInput); // Vulnerable: unsafe deserialization of user input...✅ Secure code example
import express from 'express';
const app = express();
app.use(express.json());
app.post('/api', (req, res) => {
try {
// Use JSON.parse instead of serialize.unserialize to safely parse data...Search for vulnerabilities in your apps for free with Fluid Attacks' automated security testing! Start your 21-day free trial and discover the benefits of the Continuous Hacking Essential plan. If you prefer the Advanced plan, which includes the expertise of Fluid Attacks' hacking team, fill out this contact form.