• Stars
    star
    135
  • Rank 269,297 (Top 6 %)
  • Language CodeQL
  • License
    GNU General Publi...
  • Created over 2 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Finding Java gadget chains with CodeQL

QLinspector

Finding Java gadget chains with CodeQL. More information in our article

Installation

Move the QLinspector.ql file to your codeql source location:

mv QLinspector.ql codeql-repo/java/ql/src/your/path/

Move the DangerousMethods.qll and the Source.qll file to the codeql lib folder:

mv DangerousMethods.qll codeql-home/codeql-repo/java/ql/lib/semmle/code/java/
mv Source.qll codeql-home/codeql-repo/java/ql/lib/semmle/code/java/security/

Usage

As described in our article three steps need to be done.

Finding new sinks

To find new sinks run the following query:

from Callable c0,  DangerousExpression de
where c0 instanceof RecursiveCallToDangerousMethod and
de.getEnclosingCallable() = c0
select c0, de

Finding new sources

To find new sources run the following query:

from Callable c0
where c0 instanceof RecursiveCallToDangerousMethod and
c0 instanceof Source
select c0

Note that both queries can result in a CodeQL error, removing the @kind path-problem metadata can fix this issue, however this metadata is required for the next query.

Linking the sources and the sinks

To link the sources and the sinks the following query can be done thanks to the edges predicate:

from RecursiveCallToDangerousMethod c0,  RecursiveCallToDangerousMethod c1, DangerousExpression de
where de.getEnclosingCallable() = c1 and
c0 instanceof Source and
hasCalls(c0, c1)
select c0, c0, c1, "recursive call to dangerous expression $@", de, de.toString()

hibernate 6.0 example

Filtering false positive

Running the above query can return a lot of false positives. To filter them the Sanitizer class has been added. You can add conditions to filter out methods. Note that for now it will apply the filter on all the chain. For example if you want to filter the getValue method:

private class Sanitizer extends Callable {
  Sanitizer(){
    hasName(["getValue"]) 
  }
}

Exploring new ideas

A lot of gadget chains are currently using the call to the getOutputProperties method of the TemplatesImpl object, new paths can be explored with this query:

from Callable c0
where c0 instanceof RecursiveCallToDangerousMethod and
c0.hasNoParameters() and 

c0.getName().matches("get%")

select c0, c0.(RecursiveCallToDangerousMethod).getDangerousExpression()

More Repositories

1

HopLa

HopLa Burp Suite Extender plugin - Adds autocompletion support and useful payloads in Burp Suite
Java
549
star
2

php_filter_chain_generator

Python
352
star
3

eos

Enemies Of Symfony - Debug mode Symfony looter
Python
234
star
4

bip

Python
188
star
5

Windows-kernel-SegmentHeap-Aligned-Chunk-Confusion

PoC exploiting Aligned Chunk Confusion on Windows kernel Segment Heap
C
171
star
6

lumina_server

Local server for IDA Lumina feature
Python
169
star
7

php_filter_chains_oracle_exploit

A CLI to exploit parameters vulnerable to PHP filter chain error based oracle.
Python
100
star
8

rulesfinder

Machine-learn password mangling rules
Rust
91
star
9

dotNIET

Python
85
star
10

ica2tcp

A SOCKS proxy for Citrix.
C
75
star
11

nord-stream

Nord Stream is a tool that allows you to list the secrets stored inside CI/CD environments and extract them by deploying malicious pipelines. It currently supports Azure DevOps and GitHub.
Python
68
star
12

vmx_intrinsics

VMX intrinsics plugin for Hex-Rays decompiler
Python
67
star
13

samsung-q60t-exploit

JavaScript
56
star
14

PS4-webkit-exploit-6.XX

Webkit exploit that give arbitrary R/W on 6.XX PS4 firmwares
JavaScript
54
star
15

shannon-dbg

Debugger for the Shannon Baseband
C
51
star
16

Prox-Ez

Python
45
star
17

CVE-2021-40539

Exploitation code for CVE-2021-40539
Python
44
star
18

CVE-2021-27246_Pwn2Own2020

Python
42
star
19

CVE-2021-3492

PoC for CVE-2021-3492 used at Pwn2Own 2021
C
41
star
20

burp-jq

Burp extension to filter JSON on the fly with JQ queries in the HTTP message viewer.
Java
41
star
21

io_uring_scanner

io_uring based network scanner written in Rust
Rust
35
star
22

CVE-2021-1782

C
35
star
23

AMSI-Bypass

Lists of AMSI triggers (VBA, JScript / VBScript)
32
star
24

Exim-CVE-2019-15846

PoC materials to exploit CVE-2019-15846
Python
31
star
25

Radmin3-Password-Cracker

Radmin Server 3 credentials dumper/cracker
C
30
star
26

CVE-2020-27950

CVE-2020-27950 exploit
C
30
star
27

bhyve

C
28
star
28

CTF-Write-ups

Some CTF Write-ups
Python
21
star
29

canon-mf644

Python
21
star
30

astrolock

A purposely vulnerable application in order to demonstrate PHP payload smuggling techniques for PNG files.
PHP
17
star
31

mojarragadget

Java
15
star
32

laravel_cookie_killer

Python
15
star
33

toy-wasm-symbexp

A toy symbolic execution engine, supporting the blog article ...
Haskell
15
star
34

yealink_tools

Reverse engineering scripts designed for extracting Yealink VOIP upgrade files
Python
12
star
35

Exim-CVE-2018-6789

PoC materials to exploit CVE-2018-6789
C
9
star
36

CaptainHook

Java
7
star
37

CVE-2019-8942

WordPress crop-image exploitation
Python
5
star
38

canon-tools

Tools used for decrypting Canon printers firmwares
Python
5
star
39

Netgear_Pwn2Own2021

Exploit used against the Netgear R6700v3 during Pwn2Own Austin 2021
Python
5
star
40

Weggli_rules_SSTIC2023

4
star
41

action-octoscan

📦 :octocat: A GitHub Action that performs a security scan of your GitHub Actions.
Shell
1
star
42

pridelocker-analysis

This repository contains a IDA Python script to recover PrideLocker ESX encryptor strings and a YARA rule
Python
1
star