My Tryst with Source Code Review

c0c0n 2014

22 August 2014

Talk Slides

Talk Abstract

This presentation is based on the personal experience when i took a task of performing pen test on all publicly available WordPress plugins (amounting to a total of 30K plugins). it soon became clear that such as task would be daunting and time consuming if done only from blackbox prospective. hence i decided to leverage both blackbox and code review process in place. The code base was in php language and at this point owing to the large codebase at hand all generic tools were failing to work on identifying various issues. It is to be noted only opensource tools were tried and tested and no commercial tool was used. The talk focuses on how quickly with help of simple scripts and by stitching generic tools the author was able to solve a lot of his problems as well as was able to perform the task with ease. The end result of phase 1 of the activities was close to 270 vulnerabilities distributed as listed below.

Vulnerability Type Count

  1. A3-Cross-Site Scripting (XSS): 211
  2. A1-Injection: 9
  3. Information Disclosure: 1
  4. Direct access authorization bypass: 1
  5. A9 Using Components with Known Vulnerabilities: 30
  6. SSRF/XSPA: 4
  7. Local File Inclusion: 6
  8. A10-Unvalidated Redirects and Forwards: 4

Some of the scripts written so far are

  1. identifying probable XSS via code review and validating the same via request call.
  2. automated installation and configuration of plugins / extension.
  3. Identifying possible SQL injection points. (in progress)
  4. identification of various access levels available for a plugin (access level map)
  5. automated information extraction and identification if there is a newer version available.
  6. automated screenshot of application based on specific conditions.
  7. automating reporting template
    and many more

AI Generated Summary

AI Generated Content Disclaimer

Note: This summary is AI-generated and may contain inaccuracies, errors, or omissions. If you spot any issues, please contact the site owner for corrections. Errors or omissions are unintended.

Presented at c0c0n 2014, “My tryst with Source Code Review” follows an Information Security Consultant through a first year of hands-on source code review with the CodeVigilant project. The deck covers the reasons for stepping away from bug bounties, how the community project targeted the WordPress plugin and theme ecosystem, the automation-first methodology that surfaced over 250 vulnerabilities, the PHP dangerous-function checklist shared with attendees, and why both open-source and commercial scanners missed findings that simple custom scripts caught.

Summary

The talk opens with the position at the time: a black-box penetration tester and tool author, project leader for Android Tamer and CodeVigilant, with a past life as a system administrator and the developer of wp-filemanager with more than one lakh downloads. Expectations were set honestly: no tool release, no highly sophisticated code, no artificial intelligence, and no deep SAST discussion, with a disclaimer that no commercial source code review tools were harmed during the exercise.

The deck reframes Linus Torvalds’ “with enough eyes all bugs are shallow” into “with enough expert eyes all bugs are shallow” and explains the motivation: become the expert eye and learn new things. Bug bounties came first, but they proved mostly about alert(‘XSS’) and X-FRAME-OPTIONS or httpOnly findings, with a small black-box surface area, so the move to code review followed even though whitebox was not exactly home ground.

The narrative then follows the project’s arc. A #nullblr meet brought fellow researcher Prajal Kulkarni into the picture, and the two started CodeVigilant, a community collaboration to make open-source software secure by finding bugs, responsibly disclosing them to authors, and publishing advisories after a sufficient interval. They picked the WordPress ecosystem: plugins and themes first, core later. The first attempt, downloading the top ten plugins and analyzing one by one, ended in frustration within days. The re-roll was to automate: download all plugins and themes, then focus on vulnerability types rather than individual plugins.

The demos and tooling walk through this automation. A quick WordPress information extractor and downloader, a simple Python script with grep/cut friendly output, fed the pipeline. The error_finder script, released at github.com/Codevigilant/error_finder, found massive amounts of Full Path Disclosure and a few direct access issues, though WordPress’ stance on FPD made reporting pointless. Understanding the ecosystem meant mapping WordPress user roles from Super Administrator to Subscriber and prioritizing unauthenticated issues first, then subscriber and contributor issues, since editors and admins already have unescaped HTML access.

The XSS hunt is the centerpiece: grepping for echo $_GET patterns produced massive entries, but the team realized content type matters. XSS works when the response is text/html and fails for JSON, XML, and JavaScript, so a second set of scripts captured proper response types. Work on OWASP A9 flagged outdated SWF binaries and old library files, and inspathx-derived error messages yielded directory traversal findings as a by-product. The phase closed with 250 plus issues across WordPress plugins.

The deck closes with phase 2 planning (authenticated SQL injection, stored/reflected XSS in the admin console, CSRF, and more), the hurdles of mapping all 30K plugins to user roles, the expanded four-person team, an appeal for volunteers and contributors who keep any bounty they earn, the PHP dangerous-function checklist for the audience, and a simple checklist for approaching source code review. A late section explains why automated scanners were not used: RATS and other open-source tools barely worked, RIPS demanded a web workflow that kept hanging, and one commercial cloud-hosted product also missed simple XSS and SQLi because CMS-specific functions like WordPress query wrappers were unknown to the scanners.

Key Themes

Notable Points

  1. Bug bounties were set aside after most programs proved to revolve around alert(‘XSS’) and X-FRAME-OPTIONS or httpOnly findings, with a small black-box surface area.
  2. CodeVigilant started with Prajal Kulkarni after the two touched bases during a #nullblr meet, and grew into a four-person team: Anant Shrivastava, Prajal Kulkarni, Chaitu, and Madhu Akula.
  3. The team released the error_finder script at github.com/Codevigilant/error_finder, which surfaced a massive amount of Full Path Disclosure and a few direct access issues.
  4. XSS hunting began with grep “echo $_GET” and moved to attempt two: extract all GET/POST/REQUEST parameters and access the URL with those parameters in place.
  5. Findings must be validated against content type: XSS works when the response is text/html and fails when it is JSON, XML, or JavaScript.
  6. OWASP A9 (Known Vulnerable Components) work identified outdated SWF binaries and old library files bundled within plugins, and inspathx error output yielded directory traversal findings as a by-product.
  7. Phase 1 closed with 250 plus issues in various WordPress plugins; Phase 2 targets authenticated issues and requires a script to map all 30K plugins with each type of access.
  8. Takeaway: when approaching source code review at scale, automate the collection and focus on vulnerability types across the entire codebase rather than reviewing individual components sequentially.
  9. Takeaway: understand the target application’s architecture, especially user roles and permission models, before prioritizing which vulnerabilities to hunt, as impact varies significantly by access level.
  10. Takeaway: maintain a language-specific checklist of dangerous functions (sinks) and user-controlled inputs (sources) to systematically identify potential vulnerabilities through grep-based searches.
  11. Takeaway: validate findings by checking response content types, and do not rely solely on automated SAST tools for CMS or framework-based code; combine automated scanning with manual review and custom scripts.
  12. Takeaway: contributors can join the team for continuous contribution with an author’s page at CodeVigilant and keep any bounty earned, or submit one-off findings for coordination, patching, and co-credited advisories.

Notable Quotes

“With enough expert eyes all bugs are shallow”

“No commercials Source code review tools were harmed during the exercise.”

“Ended up getting frustrated in couple of days”

“Focus on vulnerability type and not on individual plugin”

“If Content type is text/html XSS works”