CI / CI configuration security checks (pull_request) Successful in 2s
CI / Capabilities and shell quality (pull_request) Successful in 15s
CI / Python tests and compilation (pull_request) Successful in 36s
CI / QMD unit tests (pull_request) Successful in 7s
CI / Build and inspect generated packages (pull_request) Successful in 16s
CI / Bash integration and installation guards (pull_request) Failing after 51s
CI / PowerShell tests on Ubuntu (pull_request) Failing after 1m45s
CI / Installed client configuration smoke tests (pull_request) Canceled after 1m24s
- Resolve contradictions: authorization is never a skipped "boundary check"; one browser token policy (BFF/HttpOnly cookies first, RFC 10017); one sanitizer-bypass rule; Angular responses are unknown until validated. - Add security rules for AI/LLM integration and Java XXE, concrete crypto and password-hashing parameters, and RFC 8725 JWT validation. - Update version-dependent guidance after checking official sources: Angular 22, TypeScript 6/7, Node 24+, .NET 10/C# 14, JDK 21-25, Spring Boot 4; add a Spring Boot and Spring Security topic. - Give every rule a unique level-1 title and scope line, keep language security files to language specifics, and fix routing for inbound vs outbound HTTP, XML parsing, and WPF/Angular parent rules. - Validate rule structure and routing in validate-config.py, with tests. - Fix CI issues found by a local run: shellcheck directive order, pinned ruff rule set, Invoke-Python test mock, CRLF-tolerant package checks, Windows-only credential test, and refreshed prompt-budget baselines. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3.6 KiB
3.6 KiB
Java Security
Apply these rules to security-sensitive Java code. Load the shared security rule for each affected boundary (API, auth, web, data, files, network, crypto, supply chain, AI); this file adds only Java specifics, and the Spring rule covers Spring Boot and Spring Security.
- Use parameterized database APIs such as
PreparedStatement. Select dynamic identifiers or sort expressions from a fixed allowlist; never concatenate untrusted data into SQL. - Resolve file paths with
root.resolve(input).normalize()and check containment withPath.startsWith(root), neverString.startsWith, which accepts/data/app2for/data/app.normalize()does not resolve symlinks; usetoRealPath()when links matter and the file exists, and account for replacement races. Check everyZipEntryname the same way. Limit file size and processing work. - Use
ProcessBuilderwith an absolute executable path and separate arguments; avoid shell interpretation. On Windows, the argument list is flattened into one command line that the target re-parses, and.bator.cmdtargets run throughcmd.exe; never pass untrusted arguments to them, and validate attacker-controlled arguments against an allowlist. - Parse untrusted XML with DTDs disabled (
http://apache.org/xml/features/disallow-doctype-declset totrue), or, where DTDs are required, with external entities and external DTD and schema access disabled (XMLConstants.ACCESS_EXTERNAL_DTDandACCESS_EXTERNAL_SCHEMAset to"",XMLConstants.FEATURE_SECURE_PROCESSINGenabled). Apply this to every factory that reads untrusted XML:DocumentBuilderFactory,SAXParserFactory,XMLInputFactory,TransformerFactory,SchemaFactory, and JAXB unmarshallers. - Deserialize into explicit allowed types and bound input size and nesting. Avoid native Java serialization for untrusted data; where it is unavoidable, install an
ObjectInputFilterallowlist. With Jackson, never enable default typing (activateDefaultTyping) or@JsonTypeInfo(use = Id.CLASS)for untrusted input; useId.NAMEwith registered subtypes or a strictPolymorphicTypeValidator. Spring Boot 4 uses Jackson 3 (tools.jackson.*packages; annotations stay incom.fasterxml.jackson.annotation). Load YAML with SnakeYAML 2.x or aSafeConstructor. Never evaluate untrusted SpEL, OGNL, or JNDI names. - Use the platform's maintained TLS, cryptographic, and secure-random APIs with the parameters in the shared cryptography rule. Always specify the full
Ciphertransformation, for exampleAES/GCM/NoPadding, becauseCipher.getInstance("AES")means ECB. UseSecureRandom, neverjava.util.Random, for security values, andMessageDigest.isEqualfor constant-time comparison. Never install trust-allX509TrustManagerorHostnameVerifierimplementations. Do not rely on the Security Manager; JDK 24+ disables it permanently. - For outbound URLs, parse with
java.net.URI(theURLconstructors are deprecated since JDK 20) and check every resolvedInetAddress(isLoopbackAddress,isLinkLocalAddress,isSiteLocalAddress,isAnyLocalAddress,isMulticastAddress); these miss IPv6 unique-localfc00::/7, carrier-grade NAT100.64.0.0/10, and IPv4-mapped IPv6, so check those explicitly. Keepjava.net.http.HttpClienton its defaultRedirect.NEVERor revalidate every hop. - For regular expressions on untrusted input, bound the input length first and avoid nested or overlapping quantifiers, because
java.util.regexhas no timeout; use RE2/J for untrusted patterns. - Encode output with the template engine's automatic escaping or the OWASP Java Encoder for the exact context; never build HTML, XML, LDAP, or JPQL from untrusted strings.