Building an Automated Machine for Discovering Privacy Violations at Scale

Suchakra Sharma (Privado Inc.)

USENIX Enigma Conference 2023 · Day 3 · Grand Ballroom

Overview

In this insightful talk at USENIX Enigma, Suchakra Sharma from Privado Inc. introduced a compelling approach to tackling the pervasive problem of privacy violations: leveraging static analysis to detect sensitive data leaks directly from code. Sharma argues that the prevailing reactive methods of privacy protection are insufficient, likening them to "brooming water" after a tap has already been turned on. Instead, he advocates for a proactive, "shift-left" strategy that empowers developers with tools to identify and remediate privacy issues early in the software development lifecycle.

Watch on YouTube · Slides

Visual summary for Building an Automated Machine for Discovering Privacy Violations at Scale by Suchakra Sharma
Visual summary for Building an Automated Machine for Discovering Privacy Violations at Scale by Suchakra Sharma

Key moments

  1. 0:00 Introduction: The privacy dilemma and reactive approach.
  2. 2:00 Concrete example of PII leaking via logs.
  3. 3:30 What is static analysis? Sources, sinks, data flows.
  4. 7:50 Understanding Code Property Graph for deep code analysis.
  5. 9:30 Introducing Privado Scan: Automating privacy static analysis.
  6. 10:40 Live demo: Privado Scan detecting data flows in code.
  7. 13:00 Visualizing detected PII data flows to external services.
  8. 16:50 Q&A and resources for community and contributions.

Building an Automated Machine for Discovering Privacy Violations at Scale

Speakers: Suchakra Sharma, Privado Inc.

Conference: USENIX Enigma

YouTube: https://www.youtube.com/watch?v=qqnehBDlA80

Overview

In this insightful talk at USENIX Enigma, Suchakra Sharma from Privado Inc. introduced a compelling approach to tackling the pervasive problem of privacy violations: leveraging static analysis to detect sensitive data leaks directly from code. Sharma argues that the prevailing reactive methods of privacy protection are insufficient, likening them to "brooming water" after a tap has already been turned on. Instead, he advocates for a proactive, "shift-left" strategy that empowers developers with tools to identify and remediate privacy issues early in the software development lifecycle.

The core of Sharma's presentation centers on the development of Privado Scan, an automated machine designed to discover privacy violations at scale. This tool harnesses the power of Code Property Graphs (CPG) to deeply understand code structure and data flows, allowing for the precise identification of Personally Identifiable Information (PII) moving from defined sources to potentially problematic sinks. The talk highlights the critical need to move beyond post-facto analysis and instead build privacy into the very fabric of software development, making it an inherent part of the coding process rather than an afterthought.

Sharma's work represents a significant contribution to the field of privacy engineering, offering a scalable, automated solution that can integrate seamlessly into developer workflows. By enabling a machine to "think like a human" in tracing data flows, Privado Scan aims to bridge the gap between complex codebases and clear privacy insights. This empowers organizations to not only comply with stringent data protection regulations but also to foster a culture of privacy by design, ultimately enhancing trust and security for end-users.

Background

▶ Watch: Introduction: The privacy dilemma and reactive approach. (0:00)

The modern privacy landscape, as eloquently described by Sharma, presents a stark dichotomy: users are often forced to either "agree to whatever and sign away your soul" or completely disengage from digital services. This lack of meaningful choice stems from a fundamental challenge in how data privacy is currently managed within software development. Traditionally, privacy operations teams are tasked with the arduous job of identifying data leaks and misconfigurations after data has been produced, stored, or transmitted. This reactive posture, while necessary, is inherently inefficient and often too late, as "at runtime detecting a leak means the game is already over."

Sharma illustrates this with a poignant example from an open-source app, Shopizer, where a seemingly innocuous log.info(username) statement can lead to massive privacy breaches. While a single developer might not consider a log entry to be sensitive, at scale, with hundreds of users and multiple logging services, this PII can proliferate across databases, third-party services like SendGrid or Sentry, and be exposed to operations personnel who have no legitimate need to view it. The current approach often involves extensive manual investigations, trying to trace data through databases, services, and third parties – a complex and often overwhelming task.

The speaker posits that the true origin and "container" of data is the code itself. Data is "produced by code," much like water flowing from a tap. Therefore, the most effective point of intervention is at the source – where the code is written. This is where static analysis comes into play. Static analysis involves analyzing computer programs "without executing them," allowing developers to "find the bugs when they will actually get executed" before they ever reach production. This proactive method allows for calm, reasoned analysis of the code, in stark contrast to the "death metal" experience of debugging runtime issues. While static analysis is not a new concept, having been foundational to mainframe systems for decades, its application to systematic, large-scale privacy violation detection is a novel and critical step forward. The goal is to empower the "folks who are building these things" to solve privacy problems at their origin.

Key Findings

▶ Watch: What is static analysis? Sources, sinks, data flows. (3:30)

The central finding presented by Suchakra Sharma is that static analysis, when applied systematically to privacy, can effectively and proactively identify sensitive data flows and potential violations at scale. This shifts the paradigm from reactive incident response to proactive prevention, embedding privacy checks directly into the development pipeline.

Specifically, the talk demonstrates several key findings:

  1. Code as the Primary Source of Truth for Privacy: Sharma firmly establishes that code is the "true container and producer of data." By analyzing code before execution, it's possible to reason about data flows calmly and accurately, catching privacy bugs "early in the software development life cycle."
  2. Feasibility of Automated PII Detection with CPGs: The talk proves that complex privacy questions can be answered by machines using Code Property Graphs (CPG). CPGs provide a comprehensive, queryable representation of code, allowing tools to track sources, sinks, taint, and data flows in a way that mimics human intuition but with machine-level precision and scalability.
  3. Identification of Diverse Privacy Sinks: The Privado Scan tool successfully identifies various types of problematic data sinks. During the demo, it showcased the detection of PII (like phone numbers and account details) flowing to:
  • Third-party services: Demonstrated with "Fast to SMS."
  • Databases: Highlighted with "HDFC Bank."
  • Internal logs/console output: Directly visible in developer tools.
  • Internal collections/APIs: PII being collected and processed within the application's own API handlers.
  1. Scalability and Customizability: The architecture of Privado Scan, utilizing YAML-based rules and a CPG engine, allows for the creation of "thousands of these queries" across "millions of lines of code." This indicates that the approach is highly scalable for large organizations and customizable to specific organizational policies or regulatory requirements.
  2. Actionable Developer-Centric Insights: The tool generates results in an open JSON format and offers a visualization dashboard, providing clear, actionable insights for developers and engineers. It not only identifies what data is leaking but also where it is originating and where it is going, empowering developers to fix issues directly. The ability to trace the full lineage of a data element (e.g., how a phone number within an Account object is being tracked) is crucial for effective remediation.

These findings collectively underscore the potential for static analysis to become an indispensable component of modern privacy programs, enabling organizations to build more secure and compliant software from the ground up.

Technical Deep Dive

▶ Watch: Introducing Privado Scan: Automating privacy static analysis. (9:30)

The technical foundation of detecting privacy violations at scale, as presented by Suchakra Sharma, lies in the sophisticated application of static analysis leveraging Code Property Graphs (CPGs). The process begins by transforming raw source code into a structured, queryable representation that machines can understand and analyze.

At its lowest level, static analysis involves several stages:

  1. Lexical Analysis: The source code (e.g., Y = X + 50) is broken down into a stream of tokens (e.g., Y, =, X, +, 50).
  2. Abstract Syntax Tree (AST): These tokens are then organized into an AST, a tree representation of the program's syntactic structure. The AST captures the hierarchical relationships between program elements.
  3. Control Flow Graph (CFG): The AST is further enhanced to create a CFG, which illustrates all possible paths that program execution might take. This includes understanding conditional statements (if-else), loops, and function calls, showing where data can flow from one point to another.
  4. Program Dependence Graph (PDG): For deeper analysis, a PDG is constructed. This graph captures both control dependencies (e.g., an if statement controlling the execution of a block) and data dependencies (e.g., the value of Z depends on Y, which depends on X). This is crucial for tracing how data values propagate through the code.

However, real-world programs are far more complex than simple one-line statements. They involve intricate structures like class member variables, local variables, annotations, and various language-specific constructs. To manage this complexity and provide a holistic view for privacy analysis, the concept of a Code Property Graph (CPG) is introduced.

A CPG is a "queryable graph which embeds a complete code knowledge." It's a powerful abstraction that combines multiple views of the code into a single, comprehensive graph database. The construction of a CPG involves layering information:

  • The foundational layer is the AST, providing the syntactic structure.
  • On top of the AST, the CFG is integrated, adding control flow information.
  • Finally, higher-level relationships and context, similar to how humans perceive code (e.g., "a patient controller defines getPatient method and contains a call"), are added. This allows the CPG to hold rich contextual data, enabling deeper questions about operators, data types, and dependencies.

There are several implementations of CPGs, but Privado Scan primarily utilizes Joern, an open-source CPG framework that has been in development for over a decade. Joern provides a Scala-based query language, allowing analysts to formulate complex questions about the codebase. For instance, one can ask: "Give me all the logging sinks that are reachable by this PII variable called location." This ability to ask precise, domain-specific questions across an entire codebase is what makes CPGs so powerful for privacy analysis.

The Privado Scan tool itself is architected with three main components:

  1. Rules: These are defined in easy-to-understand YAML format. These rules specify what constitutes a source of PII (e.g., an HTTP request parameter, a database column containing phone_number), what constitutes a sink (e.g., a logging function, a third-party API call, a file write), and how to track taint between them.
  2. Engine: This is the core analysis component. It takes the target codebase, generates its CPG (using Docker for dependency management and environment isolation), and then converts the YAML rules into CPG queries. It executes these queries against the CPG to identify specific data flows where PII moves from a defined source to a prohibited sink. The engine is responsible for language detection (e.g., Java), parsing, and tagging interesting literals, databases, and APIs within the code.
  3. UX (User Experience): This component provides the interface for users. It's primarily a command-line interface (CLI) that outputs results in a standardized JSON format. There's also an optional cloud UI for visualization, which allows users to explore the detected data flows in an interactive dashboard, showing the full lineage of PII from its origin to its destination.

The process of scanning with Privado Scan involves:

  • privado scan <repository_path>: The command initiates the scan.
  • Dockerization: The analysis often runs within Docker containers, ensuring consistent environments and handling tool dependencies.
  • Language Detection: Automatically identifies the programming language (e.g., Java).
  • Dependency Resolution: Fetches necessary dependencies for accurate parsing.
  • CPG Generation: Builds the comprehensive Code Property Graph of the application.
  • Query Execution: Runs thousands of predefined and custom queries against the CPG to find PII flows.
  • Result Generation: Produces privado.json with a summary of findings, including identified data elements, third-party interactions, and detailed data flow paths.

By combining the robust capabilities of CPGs with a user-friendly, rule-driven engine, Privado Scan offers a potent technical solution for automating the discovery of privacy violations, allowing for deep, contextual analysis that was previously only achievable through painstaking manual effort.

Demo / Proof of Concept

▶ Watch: Live demo: Privado Scan detecting data flows in code. (10:40)

The talk included a live demonstration of Privado Scan, showcasing its capabilities in identifying privacy violations within a sample application. The speaker scanned a mock "banking system backend" codebase, illustrating the tool's practical application.

The demo began with the simple execution of the command: privado scan <path_to_banking_system_backend>. The tool, running via Docker, initiated its process by first detecting the programming language (Java in this case) and relevant configuration files. It then proceeded to download necessary dependencies and parse the code, which the speaker humorously noted allows for a "calm" analysis akin to "listening to classical music" due to the static nature of the process.

After the analysis completed, Privado Scan presented a summary of its findings. The output included:

  • A count of identified "data elements" (e.g., 11 in the demo).
  • A count of "third-party" interactions (e.g., 1).
  • A note that all detailed information was available in the privado.json file.

The demo then transitioned to visualizing these results on an optional "community dashboard," which provides a more interactive and digestible view of the findings. The dashboard displayed:

  • A summary of data elements and "sensitive inventory."
  • A list of all detected data flows.

A key highlight was the tool's ability to differentiate between PII that is present but not flowing anywhere (e.g., "date of birth" was found but had zero flows, indicating no immediate leak) versus PII that is being actively transmitted. The "phone number" variable served as a prime example of problematic flows. The dashboard clearly illustrated that the phone number was:

  • Shared with a third-party service: Specifically, "Fast to SMS." The tool could even delve deeper, showing that the phone number was being concatenated into a string for a URL connection to this service.
  • Stored in a database: Identified as "HDFC Bank," indicating persistence of sensitive data.
  • Leaked to the console: A common oversight where PII might be printed during development or debugging.
  • Processed internally: Collected through internal APIs and handlers, such as addAccountHandler. The tool intelligently tracked that an Account object contained the phone number, and thus, if the Account object was being collected, the phone number was implicitly collected too.

Furthermore, the demo touched upon an "inventory" feature, which allows for a "reverse lookup." For example, an analyst could query what data elements are being shared with "Fast to SMS." The tool revealed that not only the "phone number" but also "account" and "password" were being shared with this third-party service, providing a comprehensive understanding of data egress.

The demo concluded with an acknowledgment that while the tool is powerful, there is ongoing work to refine the YAML rules for better accuracy and coverage, and contributions to the open-source project are welcomed. The demonstration effectively proved that Privado Scan can automatically and comprehensively identify complex PII data flows across various internal and external sinks, providing crucial insights for developers and privacy engineers.

Defensive Implications

▶ Watch: Q&A and resources for community and contributions. (16:50)

The proactive approach championed by Suchakra Sharma and embodied in Privado Scan carries significant defensive implications for organizations striving to protect sensitive data and comply with privacy regulations. By shifting privacy analysis to the left of the development lifecycle, defenders gain powerful new capabilities:

  1. Early Detection and Remediation ("Shift Left"): The most critical implication is the ability to identify and fix privacy vulnerabilities at the earliest possible stage – during coding and development, rather than after deployment or a breach. This dramatically reduces the cost and complexity of remediation, preventing PII from ever reaching production systems where it can be exploited or leaked.
  2. Empowering Developers with Privacy-by-Design: Instead of privacy being an external audit performed by a separate team, tools like Privado Scan integrate privacy checks directly into the developer's workflow. Developers receive immediate, actionable feedback about PII flows they might inadvertently introduce. This fosters a culture of privacy-by-design, making privacy considerations an inherent part of software development rather than an afterthought.
  3. Automated, Scalable Privacy Audits: Manual code reviews for privacy are time-consuming, error-prone, and don't scale with large, rapidly evolving codebases. Privado Scan automates this process, allowing for continuous, systematic scanning of millions of lines of code. This ensures consistent application of privacy policies across an entire software portfolio.
  4. Enhanced Data Governance and Transparency: By providing a detailed map of where PII originates, how it flows, and where it is stored or shared, organizations gain unprecedented visibility into their data landscape. This understanding is fundamental for robust data governance, allowing defenders to identify data proliferation, unnecessary data collection, and unapproved third-party data sharing.
  5. Proactive Compliance with Regulations: Regulations like GDPR, CCPA, and others mandate strong data protection and accountability. Tools that automatically identify PII flows from code provide tangible evidence of due diligence and proactive compliance efforts. Organizations can demonstrate that they are actively scanning for and mitigating privacy risks, which can be crucial during audits or in the event of an incident.
  6. Targeted Risk Assessment: The ability to trace specific PII elements to various sinks (e.g., internal logs vs. external third parties) allows security teams to conduct more targeted risk assessments. They can prioritize remediation efforts based on the sensitivity of the data and the severity of the potential exposure.
  7. Customizable Policy Enforcement: The YAML-based rule engine allows organizations to define and enforce their specific privacy policies and regulatory requirements. This means defenders can tailor the tool to look for company-specific PII, approved data handling patterns, or prohibited data sharing practices, ensuring that the analysis aligns with their unique risk profile.
  8. Integration into CI/CD Pipelines: Privado Scan is designed to be integrated into Continuous Integration/Continuous Delivery (CI/CD) pipelines. This means every code commit or build can trigger an automated privacy scan, ensuring that new privacy vulnerabilities are caught before they are merged or deployed, effectively gatekeeping privacy risks.

In essence, Privado Scan transforms privacy defense from a reactive, resource-intensive cleanup operation into a proactive, automated, and developer-empowering process, significantly strengthening an organization's overall security posture.

Key Takeaways

  • Shift Left for Privacy: Proactively addressing privacy violations at the code level using static analysis is far more effective and less costly than reactive, post-deployment detection.
  • Code Property Graphs (CPGs) as the Foundation: CPGs provide a powerful, queryable, and comprehensive representation of code, enabling deep analysis of data flows and precise identification of PII sources, sinks, and taint.
  • Automated, Scalable PII Detection: Tools like Privado Scan can automatically identify complex PII data flows to various sinks (e.g., third-party services, databases, internal logs, console output) across large codebases.
  • Empower Developers: Integrating static analysis for privacy into the development workflow provides developers with immediate, actionable feedback, fostering a culture of privacy-by-design and reducing the burden on privacy operations teams.
  • Customizable and Actionable Insights: With YAML-based rules and clear JSON/dashboard outputs, organizations can tailor privacy checks to their specific policies and gain transparent, traceable insights into data provenance and flow for enhanced governance and compliance.

About the Speaker(s)

Suchakra Sharma is a key figure at Privado Inc., where he focuses on building tools for automated privacy violation discovery. He has an extensive background in analyzing computers and code, having completed his PhD in Computer Engineering from Polytechnic Montreal. Beyond his professional endeavors in cybersecurity, Suchakra also enjoys creative pursuits such as writing poems and collecting film photos.

Reviews

Dr. Zero (Offensive Security Researcher) — SOLID

This is a practical application of Code Property Graphs to automate privacy compliance. The speaker took Joern, wrote YAML rules for PII sinks, and built a usable CLI around it. It's solid engineering that turns privacy theater into a CI/CD pipeline problem, even if the underlying static analysis concepts are decades old.

Heather Calloway (CISO) — SOLID

A highly relevant look at using Code Property Graphs (CPGs) to detect privacy violations and PII leaks directly in the CI/CD pipeline. By shifting privacy checks left, this approach offers a credible way to prevent the expensive, reactive runtime cleanups that drag down incident response teams and trigger regulatory exposure.

→ Top-rated talks at USENIX Enigma Conference 2023

All talks from USENIX Enigma Conference 2023