Security Engineering

A web application deserializes objects that clients send in a cookie, and a test shows an attacker can craft a payload that runs code on the server. Which three actions reduce this risk? (Choose three.)

Choose 3 answers

Show the answer

Correct answersA. Use a data-only format such as JSON with schema validationB. Verify an HMAC over the serialized data before deserializing itC. Allow only an approved list of object types to be deserialized

AWhy this is right: A data-only format with schema validation carries no executable object behavior, so crafted payloads cannot run code.

BWhy this is right: An HMAC lets the server reject any serialized data a client has altered or forged.

CWhy this is right: An allowlist stops attacker-chosen classes from being instantiated during deserialization.

DWhy not this: Base64 is a reversible encoding, not protection; an attacker can decode, craft and re-encode a payload.

EWhy not this: These flags guard the cookie in transit and from page scripts, but the attacker edits their own cookie directly.

Insecure deserialization is prevented by rejecting tampered data (HMAC), limiting which types can be rebuilt, and avoiding native object formats in favour of validated data-only formats. Base64 is only an encoding that anyone can reverse, and the Secure and HttpOnly flags protect the cookie in transit and from scripts, not from a client who edits it.