bubblewrap icon indicating copy to clipboard operation
bubblewrap copied to clipboard

Code issues

Open noppnopp opened this issue 5 years ago • 5 comments

Running bubblewrap through the static code analytics tool sonarqube revealed some areas that need a closer look: https://sonarcloud.io/dashboard?id=noppnopp_bubblewrap

If I am not mistaken, the "vulnerabilities" listed regarding strcpy and strcat are not exploitable since the checks are done manually. On the other hand I am not aware of any reason not to use strncpy instead to be save.

There are some other areas that indicate further issues. I hope this can be helpful to impove the quality of the code.

noppnopp avatar Mar 08 '20 21:03 noppnopp

The leak in utils.c is a false-positive.

Personally I think just dumping a link to what is most-likely bogus issues isn't helpful. If you find real issues submit a PR.

TingPing avatar Mar 09 '20 00:03 TingPing

I looked at the first "bug" and it was bogus too.

alexlarsson avatar Mar 09 '20 10:03 alexlarsson

Is replacing strcpy with strncpy something you consider helpful? If so I will try to find the time to work on that, even if only to have bubblewrap comply with secure coding guidelines.

if you know any reason why this should not be change please tell me.

noppnopp avatar Mar 09 '20 22:03 noppnopp

It wouldn't hurt I guess, but its far from a priority.

alexlarsson avatar Mar 10 '20 07:03 alexlarsson

strncpy isn't silver bullet that can be applied with simple search & replace. For example:

Although choosing a suitable value for n ensures that strncpy() will never overrun dst, it turns out that strncpy() has problems of its own. Most notably, if there is no null terminator in the first n bytes of src, then strncpy() does not place a null terminator after the bytes copied to dst. If the programmer does not check for this event, and subsequent operations expect a null terminator to be present, then the program is once more vulnerable to attack. The vulnerability may be more difficult to exploit than a buffer overflow, but the security implications can be just as severe.

Usage of strncpy is deprecated in linux kernel.

strscpy is better replacement but it still needs understanding the code first.

More info avalaible at: https://lwn.net/Articles/507319/ https://lwn.net/Articles/659214/

Maryse47 avatar Mar 10 '20 12:03 Maryse47