Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Golang - Server Side Template Injection #15193

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

aydinnyunus
Copy link
Contributor

Pull Request: Add Go SSTI Method Detection Query for CodeQL

Overview

This pull request introduces a new CodeQL query specifically designed to detect Server-Side Template Injection (SSTI) vulnerabilities in Go applications. SSTI in Go can occur when user input is dynamically embedded into templates, leading to potential code execution or other security breaches. This query focuses on identifying patterns in Go code that could be exploited through SSTI.

Changes Introduced

  • New Query Added: SSTI.ql - Detects patterns in Go applications that are potentially vulnerable to SSTI.
  • Experimental Code Samples: Provided in the CWE-1336/ directory, showcasing both vulnerable (bad) and secure (good) code implementations related to SSTI in Go.
  • Documentation: Comprehensive documentation detailing the query's purpose, implementation, and the nature of SSTI vulnerabilities in Go.

Implementation Details

  • The query scans for instances where user input may be unsafely incorporated into server-side templates.
  • Focuses on Go's template package and common patterns where SSTI vulnerabilities are likely to occur.

Testing and Validation

  • Rigorously tested against various synthetic Go code samples (included in the pull request).
  • Evaluated to ensure a low false positive rate and minimal performance impact on large Go codebases.

Future Work

  • Plans to enhance the detection capabilities for more complex and nuanced SSTI scenarios in Go.
  • Welcoming community contributions for further improvements and updates.

References

@ghsecuritylab
Copy link
Collaborator

Hello aydinnyunus 👋
You have submitted this pull request as a bug bounty report in the github/securitylab repository and therefore this pull request has been put into draft state to give time for the GitHub Security Lab to assess the PR. When GitHub Security Lab has finished assessing your pull request, it will be marked automatically as Ready for review. Until then, please don't change the draft state.

In the meantime, feel free to make changes to the pull request. If you'd like to maximize payout for your this and future submissions, here are a few general guidelines, that we might take into consideration when reviewing a submission.

  • the submission models widely-used frameworks/libraries
  • the vulnerability modeled in the submission is impactful
  • the submission finds new true positive vulnerabilities
  • the submission finds very few false positives
  • code in the submission is easy to read and will be easy to maintain
  • documentation is written clearly, highlighting the impact of the issue it finds and is written without grammatical or other errors. The code samples clearly show the vulnerability
  • the submission includes tests, change note etc.

Please note that these are guidelines, not rules. Since we have a lot of different types of submissions, the guidelines might vary for each submission.

Happy hacking!

@ghsecuritylab ghsecuritylab marked this pull request as draft December 22, 2023 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants