Text of securitylab.github.com › ctf › codeql-and-chill as Styx crawled it on Nov 20, 2026. The page may have changed since. Only its words are kept, without pictures or layout, and only the first part of a long page.

Open the live page

CodeQL and Chill - The Java Edition | GitHub Security Lab

skip to content Resources Open Source Community Enterprise / Security Lab Research Advisories CodeQL Wall of Fame Resources Open Source Community Enterprise Events Get Involved capture the flag CodeQL and Chill - The Java Edition About this challenge This CTF is now closed! You can still challenge yourself for fun! Check the reference answers Start Date May 6, 2020 Deadline June 12, 2020 Language Java Difficulty Looking for a vulnerability hunting challenge?

Then this Java CTF challenge is for you! You will hone your bug finding skills and also learn all about CodeQL's taint tracking features. Your mission, should you choose to accept it, is to hunt for a recently identified vulnerability in a popular container management platform. This vulnerability enabled attackers to inject arbitrary Java EL expressions, leading to a pre-auth Remote Code Execution (RCE) vulnerability.

Using CodeQL to track tainted data from a user-controlled bean property to a custom error message, you'll learn to fill in any gaps in the taint tracking to carve a full data flow path to the vulnerability. Pre-requisite To complete this challenge, participants must have some prior knowledge of CodeQL and its libraries for data flow analysis. Capture the Flag challenge using CodeQL for JavaScript , or the CodeQL training examples for Java .

Then come back here and take your chances with this CTF. How to submit? Create a secret GitHub gist or a private GitHub repository. Submit your write-up, in your gist or in the README.md of your repo, or in another file of your repo. You can add the responses either directly in the main write-up, or in separate files, that you reference in your main write-up. When you are ready to submit, just email ctf@github.com with the link to your gist or to your repo (If you are using a private repo, first invite the user securitylab-ctf as a collaborator).

Need help? Your first stop should be the documentation . If you need more help on some CodeQL concepts, visit our forum . Be careful, don't give away your solutions to other competitors ;-) You can contact us at ctf@github.com Introduction Many applications, including some container management platforms, use Java Bean Validation to validate that Java bean objects in the application satisfy certain constraints set by the developers, and it renders custom error messages if those constraints are not satisfied.

However, in some cases the beans are unmarshalled from user-controlled data, such as HTTP requests. If the beans' properties are not properly sanitized before being used in the custom error message, an attacker can inject arbitrary Java EL expressions into the bean properties, which will lead to Remote Code Execution when the error message is rendered. Read more about the issue in our advisory . In this challenge, you’ll use CodeQL to track the flow of tainted data from user-controlled bean properties to custom error messages, and identify the known injection vulnerabilities.

You will also learn how to customize the CodeQL data flow analysis for Java, to help you explore source code better and find a wider range of related vulnerabilities. Challenge problem The platform uses Java Bean Validation (JSR 380) custom constraint validators such as com.netflix.titus.api.jobmanager.model.job.sanitizer.SchedulingConstraintSetValidator . Read the Bean Validation 2.0 spec to learn about custom validators and what type of interpolations take place when custom constraint error messages are rendered.

When building custom constraint violation error messages, it is important to understand that they support different types of interpolation, including Java EL expressions . Therefore if an attacker can inject arbitrary data in the error message template being passed to ConstraintValidatorContext.buildConstraintViolationWithTemplate() 's first argument, they will be able to run arbitrary Java code. These error message templates are sinks for injection vulnerabilities.

Unfortunately, it is common that validated bean properties flow into the custom error message. These must be validated against the constraints as they are likely to be sources of user-controlled data. As an example, consider this code in SchedulingConstraintSetValidator.java . Here container is an object that is being validated (and so is likely to be untrusted), but its properties end up in the set common , which is used to create an error message template without sanitization. @Override public boolean isValid (Container container, ConstraintValidatorContext context) { if (container == null ) { return true ; } Set<String> common = new HashSet<>(container.getSoftConstraints().keySet()); common.retainAll(container.getHardConstraints().keySet()); if (common.isEmpty()) { return true ; } context.buildConstraintViolationWithTemplate( "Soft and hard constraints not unique.

Shared constraints: " + common ).addConstraintViolation().disableDefaultConstraintViolation(); return false ; } In this challenge, we want to identify occurrences of this pattern where user-controlled objects, potentially containing Java EL expressions, will flow into error messages. Setup instructions Install the Visual Studio Code IDE . Go to the CodeQL starter workspace repository , and follow the instructions in that repository's README.

When you are done, you should have the CodeQL extension installed and the vscode-codeql-starter workspace open in Visual Studio Code. Download and unzip this CodeQL database , which corresponds to unpatched revision 8a8bd4c . Import the database into Visual Studio Code ( see documentation ). Step 1: Data flow and taint tracking analysis As explained in the introduction, reporting these issues will involve tracking the flow of tainted data through the application.

In this step we will prepare the basic building blocks for a CodeQL taint tracking analysis : sources and sinks . Step 1.1: Sources The sources of tainted data are the bean properties that go through constraint validation. In the code, these can be found as the first parameter of ConstraintValidator.isValid(...) . Write a CodeQL predicate that identifies these call arguments: predicate isSource ( DataFlow :: Node source ) { /* TODO describe source */ } To test your predicate, use the Quick Evaluation command (Right-click > CodeQL: Quick Evaluation ).

You should get 6 results. Hints: Make sure you catch only the implementations of methods defined in the ConstraintValidator interface. For example this case should not be considered as a source. There is a convenient class RemoteFlowSource that tells you when a particular data flow node is obtained from remote user input. Pay attention to get only results that pertain to the project source code. Bonus This optional improvement will be taken into account only for distinguishing submissions that are very close in quality and completeness.

You will notice that this implementation will mark every validated bean property as a source of taint. But we want to get only the user-controlled sources. We are not interested in bean properties that an attacker cannot control, such as when the bean comes from unmarshaling an application configuration file. Consider improving your predicate so we only consider cases where the bean type is bound to user-controllable data such as a JAX-RS endpoint.

Step 1.2: Sink The injection sinks we are considering occur as the first argument of a call to ConstraintValidatorContext.buildConstraintViolationWithTemplate(...) . Write a CodeQL predicate to identify these sinks. predicate isSink ( DataFlow :: Node sink ) { /* TODO describe sink */ } Quick evaluation of your predicate should give you 5 results. Step 1.3: TaintTracking configuration Before going any further, we recommend that you quick-eval your isSource and isSink predicates to make sure both are matching the issue described above in SchedulingConstraintSetValidator.java .

This case will be our main target issue for the rest of this challenge. All done? Ok, so now let'

The rest of this page is on the live site.