Commit a3cc253
Add parameter type signatures for IL and JVM methods (#358)
* Add parameter type signatures for IL methods/calls
Extract and propagate parenthesized parameter type signatures to enable overload-precise identification and matching of methods and unresolved call targets.
- Extractor: ILExtractor now emits il_method_param_signature and il_call_target_param_signature tuples.
- DB schema: Added il_method_param_signature and il_call_target_param_signature to semmlecode.binary.dbscheme.
- QL API/AST: Exposed/getters for param signatures across CilInstructions, IR, InstructionSig, TranslatedElement/Function/Instruction and transform layers so signatures flow through translation.
- Translated implementations: TranslatedCilMethod and relevant translated call/new-object logic return the extracted signatures; non-CIL backends return wildcards where appropriate.
- VulnerableCalls: Expanded the vulnerableCallModel and related predicates to include paramSignature and updated matching logic to accept exact signatures or wildcard '*'.
- Models: Updated example YAML models to include a '*' paramSignature for existing entries.
This change improves precision when matching overloaded methods for analyses such as vulnerable-call detection.
* Add method param signatures and JVM stack metadata
Expose a getParamSignature API on InstructionSig (and the TransformInstruction implementation) to return parenthesized parameter-type signatures (e.g. "(System.String,System.Int32)"). Extend the extraction DB schema with il_method_param_signature and il_call_target_param_signature to enable overload-precise method identification, and add jvm_stack_height and jvm_stack_slot tables to record JVM stack heights and map stack slots to producer instructions to simplify stack-based dataflow analysis.
* Include same-assembly method definitions in vulnerable method closure
For root cause mode analysis, where the vulnerable methods being traced are
defined in the same binary being analyzed (not referenced cross-assembly),
getAVulnerableMethod needs a base case that matches method definitions by
their fully-qualified name and parameter signature.
Previously, only cross-assembly calls via ExternalRefInstruction were matched
as the base case. Intra-assembly calls are handled by the existing transitive
getStaticTarget() clause, but the closure never started because the base case
only found external ref call sites.
The new clause matches methods defined in the current binary against the model,
respecting the paramSignature field (including wildcard '*'). For standard
cross-assembly analysis this is a no-op since the model methods won't be
defined in the binary being analyzed.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Sync JVM extractor dbscheme with ql lib
The ql lib dbscheme was updated with il_method_param_signature,
il_call_target_param_signature, jvm_stack_height, and jvm_stack_slot tables
but the JVM extractor's copy was not updated. This causes a schema mismatch
when building a JVM database and then running the binary-ql queries against it.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Add parameter type signature extraction for JVM bytecode
The CIL extractor already emits il_method_param_signature and
il_call_target_param_signature for overload-precise method matching.
This commit adds the same capability to the JVM bytecode extractor.
JVM extractor changes:
- ParseParamSignature: converts JVM descriptors (e.g. '(Ljava/lang/Object;JJ)V')
to human-readable signatures (e.g. '(Object,long,long)')
- ExtractMethod: emits il_method_param_signature for method definitions
- ExtractMethodRef: emits il_call_target_param_signature for call sites
QL library changes:
- JvmMethod: add getParamSignature() backed by il_method_param_signature
- JvmInvoke: add getParamSignature() backed by il_call_target_param_signature
- TranslatedJvmInvoke: wire getExternalParamSignature to instr.getParamSignature()
- TranslatedJvmFunction: use method.getParamSignature() instead of wildcard '*'
VulnerableCalls.qll:
- VulnerableMethodCall: handle case where extRef lacks param signature
(backwards compat for databases built before this change)
- Root cause base case: handle functions with wildcard param signature
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix JVM param signature to use JVM-specific dbscheme table
il_call_target_param_signature references @il_instruction which is incompatible
with JVM's @jvm_instruction type. Add jvm_call_target_param_signature table for
JVM call target signatures and update the extractor and QL to use it.
Also sync all extractor dbschemes (JVM and CIL) with the canonical ql/lib copy.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 3f4d327 commit a3cc253
20 files changed
Lines changed: 356 additions & 22 deletions
File tree
- binary
- extractor
- cil
- Semmle.Extraction.CSharp.IL
- jvm
- Semmle.Extraction.Java.ByteCode
- ql
- lib
- semmle/code/binary/ast
- internal
- ir
- internal
- Instruction0
- TransformInstruction
- src/VulnerableCalls
- models
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
114 | 119 | | |
115 | 120 | | |
116 | 121 | | |
| |||
182 | 187 | | |
183 | 188 | | |
184 | 189 | | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
185 | 194 | | |
186 | 195 | | |
187 | 196 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2467 | 2467 | | |
2468 | 2468 | | |
2469 | 2469 | | |
| 2470 | + | |
| 2471 | + | |
| 2472 | + | |
| 2473 | + | |
| 2474 | + | |
| 2475 | + | |
| 2476 | + | |
| 2477 | + | |
| 2478 | + | |
| 2479 | + | |
| 2480 | + | |
| 2481 | + | |
| 2482 | + | |
| 2483 | + | |
| 2484 | + | |
| 2485 | + | |
| 2486 | + | |
| 2487 | + | |
| 2488 | + | |
| 2489 | + | |
| 2490 | + | |
| 2491 | + | |
2470 | 2492 | | |
2471 | 2493 | | |
2472 | 2494 | | |
| |||
2990 | 3012 | | |
2991 | 3013 | | |
2992 | 3014 | | |
| 3015 | + | |
| 3016 | + | |
| 3017 | + | |
| 3018 | + | |
| 3019 | + | |
| 3020 | + | |
| 3021 | + | |
| 3022 | + | |
| 3023 | + | |
| 3024 | + | |
Lines changed: 70 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
145 | 149 | | |
146 | 150 | | |
147 | 151 | | |
| |||
647 | 651 | | |
648 | 652 | | |
649 | 653 | | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
650 | 660 | | |
651 | 661 | | |
652 | 662 | | |
| |||
782 | 792 | | |
783 | 793 | | |
784 | 794 | | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
785 | 855 | | |
786 | 856 | | |
787 | 857 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2467 | 2467 | | |
2468 | 2468 | | |
2469 | 2469 | | |
| 2470 | + | |
| 2471 | + | |
| 2472 | + | |
| 2473 | + | |
| 2474 | + | |
| 2475 | + | |
| 2476 | + | |
| 2477 | + | |
| 2478 | + | |
| 2479 | + | |
| 2480 | + | |
| 2481 | + | |
| 2482 | + | |
| 2483 | + | |
| 2484 | + | |
| 2485 | + | |
| 2486 | + | |
| 2487 | + | |
| 2488 | + | |
| 2489 | + | |
| 2490 | + | |
| 2491 | + | |
2470 | 2492 | | |
2471 | 2493 | | |
2472 | 2494 | | |
| |||
2966 | 2988 | | |
2967 | 2989 | | |
2968 | 2990 | | |
| 2991 | + | |
| 2992 | + | |
| 2993 | + | |
| 2994 | + | |
| 2995 | + | |
| 2996 | + | |
| 2997 | + | |
| 2998 | + | |
| 2999 | + | |
| 3000 | + | |
| 3001 | + | |
| 3002 | + | |
| 3003 | + | |
| 3004 | + | |
| 3005 | + | |
| 3006 | + | |
| 3007 | + | |
| 3008 | + | |
| 3009 | + | |
| 3010 | + | |
| 3011 | + | |
| 3012 | + | |
| 3013 | + | |
| 3014 | + | |
| 3015 | + | |
| 3016 | + | |
| 3017 | + | |
| 3018 | + | |
| 3019 | + | |
| 3020 | + | |
| 3021 | + | |
| 3022 | + | |
| 3023 | + | |
| 3024 | + | |
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
144 | 147 | | |
145 | 148 | | |
146 | 149 | | |
| |||
430 | 433 | | |
431 | 434 | | |
432 | 435 | | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
433 | 439 | | |
434 | 440 | | |
435 | 441 | | |
| |||
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
67 | 70 | | |
68 | 71 | | |
69 | 72 | | |
| |||
1209 | 1212 | | |
1210 | 1213 | | |
1211 | 1214 | | |
| 1215 | + | |
| 1216 | + | |
1212 | 1217 | | |
1213 | 1218 | | |
1214 | 1219 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
28 | 31 | | |
29 | 32 | | |
30 | 33 | | |
| |||
302 | 305 | | |
303 | 306 | | |
304 | 307 | | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
305 | 311 | | |
306 | 312 | | |
307 | 313 | | |
| |||
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
28 | 31 | | |
29 | 32 | | |
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
176 | 176 | | |
177 | 177 | | |
178 | 178 | | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
179 | 182 | | |
180 | 183 | | |
181 | 184 | | |
| |||
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
263 | 263 | | |
264 | 264 | | |
265 | 265 | | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
266 | 272 | | |
267 | 273 | | |
268 | 274 | | |
| |||
0 commit comments