A Java application keeps session state as a serialized object in a client-supplied cookie. A tester gets remote code execution by altering the object bytes, with no SQL or script characters involved. What is the best fix?
Show the answer
Correct answerD. Replace native serialization with a data-only format and validate it against a schema
AWhy not this: This blocks SQL injection, but no SQL was involved in this attack.
BWhy not this: TLS protects traffic in transit, but the attacker supplies the cookie from the client side.
CWhy not this: Output encoding stops XSS in browsers, not code execution during server-side deserialization.
DWhy this is right: A data-only format with validation stops untrusted bytes from being turned into live objects.
Deserializing attacker-controlled bytes can instantiate unexpected classes and run code, so the app should not rebuild objects from untrusted input; a simple data format with schema validation avoids it. Parameterized queries stop SQL injection, which is not what happened here.