Draft: fix: resolve deserialization vulnerability
Relates to issue https://gitlab.com/gitlab-da/tutorials/security-and-governance/WebGoat/-/issues/1
Changes
This merge request fixes the deserialization vulnerability (CWE-502) in the WebGoat project by implementing secure deserialization with class whitelisting:
1. Created SafeObjectInputStream.java
- New secure class extending
ObjectInputStreamwith whitelisting mechanism - Overrides
resolveClass()to validate all deserialized classes - Whitelists only safe classes:
VulnerableTaskHolder,LocalDateTime,String, andjava.time.Ser - Throws
ClassNotFoundExceptionfor unauthorized deserialization attempts - Includes proper SPDX license header matching project standards
2. Updated InsecureDeserializationTask.java
- Replaced
ObjectInputStreamwithSafeObjectInputStreamfor secure token deserialization - Added required import for
SafeObjectInputStream
3. Updated SerializationHelper.java
- Replaced
ObjectInputStreamwithSafeObjectInputStreaminfromString()method - Added required import for
SafeObjectInputStream - Ensures all deserialization operations use the secure implementation
Security Improvements:
-
✅ Mitigates CWE-502 (Deserialization of Untrusted Data) -
✅ Prevents malicious payload execution through class whitelisting -
✅ Maintains legitimate lesson functionality with whitelisted classes -
✅ Provides clear error messages for debugging unauthorized attempts -
✅ Follows OWASP secure coding guidelines
Edited by Fern