Skip to content

feat(java): detect messaging ConnectionFactory constructed from a non-literal URL (SSRF, CWE-918) - #160

Open
ai-anant wants to merge 2 commits into
CodeVigilant:mainfrom
ai-anant:rule/java-jenkins-ssrf-connectionfactory-nonliteral-url
Open

feat(java): detect messaging ConnectionFactory constructed from a non-literal URL (SSRF, CWE-918)#160
ai-anant wants to merge 2 commits into
CodeVigilant:mainfrom
ai-anant:rule/java-jenkins-ssrf-connectionfactory-nonliteral-url

Conversation

@ai-anant

Copy link
Copy Markdown

Adds a Java rule for Jenkins plugins (new java/jenkins/ssrf tree):

Pattern: a messaging connection factory (e.g. JmsConnectionFactory / ActiveMQConnectionFactory / any *ConnectionFactory) is instantiated with a non-literal URL and used to open an outbound broker connection. When that URL is derived from request, job-config, or other config/SCM-controlled data and no host allowlist is enforced, an attacker-influenced value makes the server open a connection to an arbitrary host/port — server-side request forgery (CWE-918).

Rule: codevigilant.java.jenkins.ssrf.connectionfactory.nonliteral-url

  • severity HIGH, mode search, metadata (CWE-918, OWASP A10:2021, technology jenkins).
  • Matches new $FACTORY($URL); where $FACTORY matches *ConnectionFactory-style class names and $URL is an identifier/expression (metavariable-regex excludes string literals) — i.e. the sink where an untrusted value reaches a network connection.

Validation: semgrep --validate passes. Fires on a positive repro
(new JmsConnectionFactory(uri);) and does not fire on the negative
(new JmsConnectionFactory("amqps://broker:5671"); literal), confirming only non-literal (potentially untrusted) URLs are flagged.

No plugin/project-specific details are included — this is the generic vulnerable code shape only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant