google / google/sanitizers

None of the sanitizers detects accesses to non-existing variadic arguments

Open
#770 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
12.5k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

Consider the following example:

```c
#include

void test(int dummy, ...) {
va_list argp;
va_start(argp, dummy);
va_arg(argp, int);
va_end(argp);
}

int main() {
test(0);
}
```

The `test` function accesses a non-existing variadic `int` argument. I expected that one of the sanitizers could find accesses to non-existing variadic arguments; however, none of them does.

I found a similar error while executing a program with a format string vulnerability with Safe Sulong (see [PR](https://github.com/voidAsterisk/Search-Algorithms/pull/1)), but could not verify the error with any of the sanitizers. While Clang triggers a warning in the linked PR (a format string with more format tags than arguments is passed to `printf`), it does not emit a warning for the initial example.

Is it possible to detect accesses to non-existing variadic arguments with reasonable effort? I guess it is hard since vararg handling bases on `libc` macros that are platform-dependent.

Contributor guide

Open the contributing guide

Research direction

Start by compiling and running the provided C example with the available sanitizers, then compare the result with the linked format-string case. Determine whether detecting missing variadic arguments is feasible with reasonable effort and define what sanitizer behavior would count as complete.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
testing-qa
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.