Summary
The ZAP ViewState add-on contains an insecure Java deserialization flaw that allows attacker-controlled JSF ViewState data to be deserialized inside the ZAP JVM.
If an attacker controls a proxied web server and embeds a malicious serialized object in the javax.faces.ViewState parameter, this can lead to arbitrary code execution when the Desktop UI renders the ViewState panel.
Affected context
This vulnerability affects environments where the Zed Attack Proxy (ZAP) ViewState add-on is used with the Desktop UI and traffic is proxied to JavaServer Faces (JSF) applications.
It becomes relevant when ZAP users inspect or render the ViewState panel for responses containing a javax.faces.ViewState parameter.
Risk arises specifically when the proxied web server is controlled by, or compromised by, an attacker who can craft arbitrary JSF ViewState payloads that are then processed by the add-on.
Exploit preconditions
- Attack surface: ZAP Desktop UI rendering of the ViewState panel for HTTP responses.
- Required access: Ability to control or influence the proxied JSF web application or its HTTP responses (e.g., malicious test server, compromised app, or man-in-the-middle).
- Trigger point: The JSFViewState.decode() method base64-decodes the javax.faces.ViewState parameter and passes the resulting bytes directly into
ObjectInputStream.readObject()when the ViewState panel is opened or rendered. - Why exploitation is possible: There is no deserialization filter, allowlist, or type restriction applied, allowing attacker-supplied serialized Java objects to be instantiated and executed within the ZAP JVM.
Why this happens
The underlying issue is a classic unsafe deserialization pattern: untrusted data is passed directly into a general-purpose Java deserialization API.
The JSFViewState.decode() method treats the base64-decoded ViewState parameter as trusted input and uses ObjectInputStream.readObject() without validation, filters, or type constraints.
This aligns with CWE-502: Deserialization of Untrusted Data, where serialized objects from external sources are rehydrated into live runtime objects, potentially triggering gadget chains or attacker-controlled behaviors during construction or method invocation.
Potential impact
- Arbitrary code execution within the ZAP Desktop JVM.
- Compromise of the ZAP user's workstation environment, subject to JVM and OS privileges.
- Theft or tampering of captured traffic, authentication tokens, and session data within ZAP.
- Installation of persistent malware or backdoors via malicious gadget chains.
- Lateral movement from the compromised ZAP instance to other connected systems or services.
General mitigation guidance
Mitigation generally focuses on eliminating unsafe deserialization of untrusted data and constraining how ViewState content is processed:
- Replace general-purpose Java deserialization (
ObjectInputStream.readObject()) with safer, data-only formats (e.g., JSON, XML, or custom token-based parsing) that do not instantiate arbitrary objects. - Apply deserialization filters, type allowlists, or explicit validation, ensuring that only expected, benign classes and structures can be processed from ViewState data.
- Treat all data received from proxied web servers as untrusted and ensure UI components never deserialize it without strict constraints.
- Run client-side tools like ZAP with least privilege and sandboxing where feasible, reducing the blast radius of potential code execution.
- Adopt secure-by-default add-on patterns where any inspection of complex state (such as JSF ViewState) uses defensive parsing rather than object deserialization.
How teams detect issues like this
Effective detection combines code-level inspection with process-wide guardrails:
- Use static analysis rules to flag uses of
ObjectInputStream.readObject()and similar APIs on data derived from HTTP parameters, headers, or other external sources. - During code review, look for UI or tooling components that deserialize data coming from remote servers, especially where type checks and filters are absent.
- Introduce security policies requiring deserialization filters or allowlists whenever Java serialization is unavoidable, and enforce these via automated checks in CI pipelines.
- Consider dynamic analysis or runtime instrumentation that logs or blocks unexpected class types during deserialization.
- Leverage generalized secure coding scanners or automated review tools that recognize CWE-502 patterns and surface them to maintainers early.

