Uncovering the Hidden Dangers: Finding Unsafe Go Code in the Wild

Johannes Lauinger, Lars Baumgärtner, Anna-Katharina Wickert, Mira Mezini
10/21/2020
cs.CRcs.SE

Official code: stg-tud/unsafe_go_study_results (1 star, Jupyter Notebook, last commit 2023-02-23).

Abstract

The Go programming language aims to provide memory and thread safety through measures such as automated memory management with garbage collection and a strict type system. However, it also offers a way of circumventing this safety net through the use of the unsafe package.

Show full abstract

While there are legitimate use cases for unsafe, developers must exercise caution to avoid introducing vulnerabilities like buffer overflows or memory corruption in general. Using go-geiger, we conducted a study on the usage of unsafe in the top 500 most popular open-source Go projects on GitHub, including a manual analysis of 1,400 code samples on how unsafe is used. From the projects using Go's module system, 38% directly contain at least one unsafe usage, and 91% contain at least one unsafe usage in the project itself or one of its transitive dependencies. Based on the usage patterns found, we present possible exploit vectors in different scenarios. Finally, we present go-safer, a novel static analysis tool to identify dangerous and common usage patterns that were previously undetected with existing tools.

View on arXivView PDF

Code Implementations(1)

Data set and replication scripts for our paper "Uncovering the Hidden Dangers: Finding Unsafe Go Code in the Wild" [@jlauinger @gh0st42 @akwick @miramezini]

13Jupyter Notebook, GoJul 23, 20203 years ago
datasetgogolangunsafe-code

Similar Papers

Cite this paper

@article{lauinger2020uncovering,
  title  = {Uncovering the Hidden Dangers: Finding Unsafe Go Code in the Wild},
  author = {Johannes Lauinger and Lars Baumgärtner and Anna-Katharina Wickert and Mira Mezini},
  year   = {2020},
  eprint = {2010.11242},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2010.11242}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2010.11242.svg)](https://codeofpaper.com/paper/2010.11242)

Discussion