tutorials1 Min Read

Resolving Checkmarx issues reported

Gorav Singal

June 03, 2018

TL;DR

Fix Checkmarx security findings by normalizing user input strings before use, applying proper validation and sanitization patterns to avoid flagged vulnerabilities.

Resolving Checkmarx issues reported

Unnormalize Input String

It complains that you are using input string argument without normalize.
By normalizing means, do some refinement of the input. The rule says, never trust user input. Always do some check on that, and normalize them.

Faulty code:

``` public static void main(String[] args) throws Exception{ Strings x = args[0]; //use x } ```

So, here we are using input variable String[] args without any validation/normalization

Java provides Normalize API. See example below:

String s = java.text.Normalizer.normalize(args[0], java.text.Normalizer.Form.NFKC);

By doing so, you are ensuring that you have normalize the user input, and are not using it directly.

Input path not canocalized

We are working on a system or disk path, which can expose unexpected files to users. If you are accepting a path from user, and you use it directly. Or, even if you are checking it. The path may be a sym link, or relative path (having .. in it). You might completely skip the validation.

In this case, it suggests you to use canonicalized paths. See example below:

String path = System.getProperty("java.io.tmpdir");
File file = new File(path);
path = file.getCanonicalPath();

Unchecked condition for loop condition

Your code is taking user input in a variable and that variable is directly being used in a loop condition. Solution is to put an input validation.
Share

Related Posts

Claude Code Skills — Build a Better Engineering Workflow

Claude Code Skills — Build a Better Engineering Workflow

Most developers use Claude Code like a search engine — ask a question, get an…

Building an AI Voicebot for Visitor Check-In — A Practical Guide to Handling the Messy Parts

Building an AI Voicebot for Visitor Check-In — A Practical Guide to Handling the Messy Parts

Every office lobby has the same problem: a visitor walks in, nobody’s at the…

Staff Engineer Study Plan for MAANG Interviews — The Complete 12-Week Roadmap

Staff Engineer Study Plan for MAANG Interviews — The Complete 12-Week Roadmap

If you’re a Senior Engineer (L5) preparing for Staff (L6+) roles at MAANG…

How to Be a Full-Time Freelancer: Resources, Finding Clients, and Building a Sustainable Business

How to Be a Full-Time Freelancer: Resources, Finding Clients, and Building a Sustainable Business

Making the leap from full-time employment to freelancing is one of the most…

Jenkins Pipeline with Jenkinsfile - How To Schedule Job on Cron and Not on Code Commit

Jenkins Pipeline with Jenkinsfile - How To Schedule Job on Cron and Not on Code Commit

Introduction In this post we will see following: How to schedule a job on cron…

Jenkins Pipeline - How to run Automation on Different Environment (Dev/Stage/Prod), with Credentials

Jenkins Pipeline - How to run Automation on Different Environment (Dev/Stage/Prod), with Credentials

Introduction I have an automation script, that I want to run on different…

Latest Posts

AI Video Generation in 2025 — Models, Costs, and How to Build a Cost-Effective Pipeline

AI Video Generation in 2025 — Models, Costs, and How to Build a Cost-Effective Pipeline

AI video generation went from “cool demo” to “usable in production” in 2024-202…

AI Models in 2025 — Cost, Capabilities, and Which One to Use

AI Models in 2025 — Cost, Capabilities, and Which One to Use

Choosing the right AI model is one of the most impactful decisions you’ll make…

AI Image Generation in 2025 — Models, Costs, and How to Optimize Spend

AI Image Generation in 2025 — Models, Costs, and How to Optimize Spend

Generating one image with AI costs between $0.002 and $0.12. That might sound…

AI Coding Assistants in 2025 — Every Tool Compared, and Which One to Actually Use

AI Coding Assistants in 2025 — Every Tool Compared, and Which One to Actually Use

Two years ago, AI coding meant one thing: GitHub Copilot autocompleting your…

AI Agents Demystified — It's Just Automation With a Better Brain

AI Agents Demystified — It's Just Automation With a Better Brain

Let’s cut through the noise. If you read Twitter or LinkedIn, you’d think “AI…

Security Ticketing and Incident Response

Security Ticketing and Incident Response

The worst time to figure out your incident response process is during an…