Skip to content

Java: replace the dead String.valueOf(CharSequence) summary with a synthetic callable - #22315

Draft
hvitved with Copilot wants to merge 4 commits into
mainfrom
copilot/fix-valueof-call-site-issue
Draft

Java: replace the dead String.valueOf(CharSequence) summary with a synthetic callable#22315
hvitved with Copilot wants to merge 4 commits into
mainfrom
copilot/fix-valueof-call-site-issue

Conversation

Copilot AI commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

java.lang.String has no valueOf(CharSequence) overload — string- and CharSequence-typed arguments compile to valueOf(Object), which is modelled as neutral. The summary row therefore matched no call site, leaving no propagating valueOf model for string-typed arguments:

String data = req.getParameter("cmd");  // source
String s1 = String.valueOf(data);       // taint lost: resolves to valueOf(Object)
Runtime.getRuntime().exec(s1);          // sink, not reported

Changes

  • java/ql/lib/ext/java.lang.model.yml: removed the ["java.lang", "String", False, "valueOf", "(CharSequence)", ...] row, which matched nothing.
  • java/ql/lib/semmle/code/java/frameworks/Strings.qll (new): a SyntheticCallable that propagates taint Argument[0]ReturnValue for String.valueOf(Object) calls whose argument's static type is a CharSequence (String, CharSequence, StringBuilder, …), where the call is equivalent to the documented CharSequence.toString(). Registered in the SyntheticCallables module in FlowSummary.qll.
  • The valueOf(Object) neutral model is kept, so arguments of arbitrary types — whose toString() may not expose tainted state — remain unaffected.
  • Tests: java/ql/test/library-tests/dataflow/string-valueof covers String, CharSequence, StringBuilder, char[] and char arguments (flow expected) and an Object-typed argument (no flow expected). Change note added.

Copilot AI and others added 2 commits August 11, 2026 08:24
…a synthetic callable for valueOf(Object) on CharSequence arguments

Co-authored-by: hvitved <3667920+hvitved@users.noreply.github.com>
Co-authored-by: hvitved <3667920+hvitved@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix valueOf method call site issue for string arguments Java: replace the dead String.valueOf(CharSequence) summary with a synthetic callable Aug 11, 2026
Copilot AI requested a review from hvitved August 11, 2026 08:25

@hvitved hvitved left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix the test failure reported by CI.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

java.lang.String: the valueOf(CharSequence) summary row matches no call site, leaving no propagating valueOf model for a string-typed argument

2 participants