<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Programming on Shivasurya</title><link>http://shivasurya.me/tags/programming/</link><description>Recent content in Programming on Shivasurya</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Tue, 10 Sep 2024 00:00:00 +0000</lastBuildDate><atom:link href="http://shivasurya.me/tags/programming/feed.xml" rel="self" type="application/rss+xml"/><item><title>CodeQL: Eindhoven Quantifier Notation</title><link>http://shivasurya.me/2024/09/10/codeql-eindhoven-quantifier-notation/</link><pubDate>Tue, 10 Sep 2024 00:00:00 +0000</pubDate><guid>http://shivasurya.me/2024/09/10/codeql-eindhoven-quantifier-notation/</guid><description>&lt;h3 id="introduction">Introduction&lt;/h3>
&lt;p>Recently, I have been thinking about aggregate functionality design for &lt;a href="https://codepathfinder.dev/">Code PathFinder&lt;/a>, &lt;a href="https://github.com/shivasurya/code-pathfinder">opensource alternative to GitHub CodeQL&lt;/a>. SQL aggregate functions such as &lt;code>SUM&lt;/code>, &lt;code>AVG&lt;/code>, &lt;code>MIN&lt;/code>, &lt;code>MAX&lt;/code> are combined with &lt;code>WHERE&lt;/code> and &lt;code>GROUP BY&lt;/code> to generate aggregate queries. However, I was wondering if there is a way to generate aggregate queries without using &lt;code>WHERE&lt;/code> and &lt;code>GROUP BY&lt;/code>. While going through &lt;a href="https://codeql.github.com/publications/ql-for-source-code-analysis.pdf">CodeQL design research paper&lt;/a>, I came across Eindhoven Quantifier Notation which is quite interesting, easy to understand and can be used to generate aggregate queries. This blog post will discuss about Eindhoven Quantifier Notation adopted by CodeQL.&lt;/p></description></item><item><title>Sherlock: Automate security code reviews with Cody AI</title><link>http://shivasurya.me/2024/06/27/automate-security-code-reviews-with-cody-ai/</link><pubDate>Thu, 27 Jun 2024 00:00:00 +0000</pubDate><guid>http://shivasurya.me/2024/06/27/automate-security-code-reviews-with-cody-ai/</guid><description>&lt;h3 id="intro">Intro&lt;/h3>
&lt;h3 id="need-for-semi-autonomous-security-code-reviews">Need for semi-autonomous security code reviews&lt;/h3>
&lt;p>My job as a security engineer (application security context) is to read source code and perform security reviews. Most of the time, mainly corelate the source code with frameworks &amp;amp; libraries, understand context where the code executes and enumerate all security risks. While there are lot of second generation SAST scanning tools in the market which is good at identifying patterns, eliminate false positive, executes and brings up results in minutes. I believe,&lt;/p></description></item><item><title>Defining Boundaries &amp; Sinks for Inter-procedural Source Sink Analysis - Part 3</title><link>http://shivasurya.me/2024/03/08/building-inter-procedural-source-sink-analysis-from-scratch-part-3/</link><pubDate>Fri, 08 Mar 2024 00:00:00 +0000</pubDate><guid>http://shivasurya.me/2024/03/08/building-inter-procedural-source-sink-analysis-from-scratch-part-3/</guid><description>&lt;p>This is the third part of the blog post series on building inter-procedural source sink analysis from scratch. In the first part, we have built the &lt;a href="https://shivasurya.me/static-analysis/sast/2023/08/27/building-simple-source-sink-analysis-from-scratch-part-1.html">intra-procedural source sink analysis&lt;/a>. In this blog post, I&amp;rsquo;ll discuss about defining boundaries, configs and sinks for inter-procedural analysis. ✨ This idea of defining boundaries and sinks is inspired from the &lt;a href="https://codeql.github.com/">CodeQL&lt;/a> library and while discussing with my colleague at &lt;a href="https://www.swag.uwaterloo.ca/">SWAG lab @ uwaterloo&lt;/a>.&lt;/p>
&lt;h3 id="plan">Plan&lt;/h3>
&lt;p>While tools like CodeQL has well-defined support for libraries and framework such as &lt;a href="https://codeql.github.com/codeql-standard-libraries/java/semmle/code/java/frameworks/android/Android.qll/module.Android.html">Android CodeQL&lt;/a> these libraries has predefined boundaries and sinks. But, start from scratch, we need to define our own boundaries and sinks. The boundaries are the entry points and sinks are the exit points.&lt;/p></description></item><item><title>Deep dive on Android Java / Kotlin Deserialization Code Execution with Semgrep Detection</title><link>http://shivasurya.me/2024/01/24/java-deserialization-rce-android-application-layer/</link><pubDate>Wed, 24 Jan 2024 00:00:00 +0000</pubDate><guid>http://shivasurya.me/2024/01/24/java-deserialization-rce-android-application-layer/</guid><description>&lt;h3 id="overview">Overview&lt;/h3>
&lt;p>In this post, we will explore code execution using Java &amp;amp; Kotlin Deserialization in Android Application. Additionally, We will discuss the Gadget Chain, Detection and Exploitation technique specific to Android. Achieving code execution in server side application via Java deserialization has higher chance of success than in client side android application. This is due to limitation of variety of loaded classes in android application. For instance &lt;code>com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl&lt;/code> is available in openJDK but not in Android JDK (but with modification). These limitation can be a blocker for loading arbitrary classes and executing payload (mostly compiled bytecode) in Android application. Well there are lot of deserialization vulnerabilities is published out there such as&lt;/p></description></item><item><title>Building Inter-procedural Source Sink Analysis from Scratch - Part 2</title><link>http://shivasurya.me/2023/09/01/building-inter-procedural-source-sink-analysis-from-scratch-part-2/</link><pubDate>Fri, 01 Sep 2023 00:00:00 +0000</pubDate><guid>http://shivasurya.me/2023/09/01/building-inter-procedural-source-sink-analysis-from-scratch-part-2/</guid><description>&lt;p>This is the second part of the blog post series on building inter-procedural source sink analysis from scratch. In the first part, we have built the &lt;a href="https://shivasurya.me/static-analysis/sast/2023/08/27/building-simple-source-sink-analysis-from-scratch-part-1.html">intra-procedural source sink analysis&lt;/a>. In this blog post, we will be building the inter-procedural source sink analysis.&lt;/p>
&lt;h3 id="plan">Plan&lt;/h3>
&lt;p>We&amp;rsquo;ll be parsing whole java project source code and generate AST using JavaParser. While traversing the AST, we will be collecting the method declaration and method invocation. We will be using graph theory algorithm to find the path from source to sink. The source is the method declaration and the sink is the method invocation. The method declaration is the node and the method invocation is the edge. While classes may contain duplicate method names with different signatures, we will be using the fully qualified method name to uniquely identify the method. The fully qualified method name is the class name + method name + method arguments. The method arguments are used to differentiate the method overloading. The method declaration is the key and method invocation is the value in the hashmap. The hashmap is used to build the graph and find the path from source to sink.&lt;/p></description></item><item><title>Building A Simple Source-Sink Analysis in Java from Scratch - Part 1</title><link>http://shivasurya.me/2023/08/27/building-simple-source-sink-analysis-from-scratch-part-1/</link><pubDate>Sun, 27 Aug 2023 00:00:00 +0000</pubDate><guid>http://shivasurya.me/2023/08/27/building-simple-source-sink-analysis-from-scratch-part-1/</guid><description>&lt;h3 id="overview-of-source-sink-analysis">Overview of Source Sink Analysis&lt;/h3>
&lt;p>Source Sink Analysis is a type of basic static analysis that detects the flow of information from a source to a sink. A source is a place where the information is coming from and a sink is a place where the information is going to. For example, a source can be a user input and a sink can be a database query. If the user input is not sanitized, it can lead to SQL Injection. Apart from source sink techniques, there are other techniques like taint analysis, control flow graph, data flow analysis, etc. which are used to detect vulnerabilities in the code. In this blog post, we will be building a simple source sink analysis in Java from scratch.&lt;/p></description></item><item><title>From ArcGIS to Mapbox: How Cody AI Made My Web App Shine</title><link>http://shivasurya.me/2023/07/02/sourcegraph-cody/</link><pubDate>Sun, 02 Jul 2023 00:00:00 +0000</pubDate><guid>http://shivasurya.me/2023/07/02/sourcegraph-cody/</guid><description>&lt;p>Imagine being a newcomer to Canada around 2019, relying on public transit to navigate the Waterloo region. Like many others, I found myself frustrated with the occasional unreliability of Google Maps when searching for public transit options. However, my luck changed when I stumbled upon a cool command line tool developed by a UWaterloo student that predicted the next bus or LRT arrival time within seconds. This discovery led me to GRT.ca, a website providing real-time transit feed updates, allowing me to track the exact location of buses and LRTs. Inspired by this newfound resource, I created a naive map using ArcGIS ESRI Maps, loading location information from the protobuf feed and deploying it on my domain, livemap.shivasurya.me. This map became my go-to tool for finding the precise location of the next bus or LRT.&lt;/p></description></item><item><title>Binary Search and Hidden Overflow 🪲</title><link>http://shivasurya.me/2022/12/04/binary-search-overflow/</link><pubDate>Sun, 04 Dec 2022 00:00:00 +0000</pubDate><guid>http://shivasurya.me/2022/12/04/binary-search-overflow/</guid><description>&lt;p>Recently I was playing with overflow vulnerabilities help of &lt;code>exploit.education&lt;/code> exercise which mostly covers basic heap, buffer overflow,
use-after-free vulnerability patterns in a contained &lt;code>qemu&lt;/code> based environment. However, I was searching for Integer overflow patterns and articles around it &amp;ldquo;how to succesfully convert a integer overflow into a remote code execution&amp;rdquo;. While reading through the vulnerability reports, I started exploring code snippets relevant to integer overflow and this blog post &lt;a href="https://ai.googleblog.com/2006/06/extra-extra-read-all-about-it-nearly.html">&lt;code>Nearly All Binary Searches and Mergesorts are Broken&lt;/code>&lt;/a> caught my eyes.&lt;/p></description></item></channel></rss>