Skip to content

Commit 3dd9440

Browse files
committed
fix readme
1 parent 006d08f commit 3dd9440

2 files changed

Lines changed: 78 additions & 3 deletions

File tree

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ codeql database analyze database.db --format=sarif-latest --output=./tob.sarif -
2929

3030
| Name | Description | Severity | Precision |
3131
| --- | ----------- | :----: | :--------: |
32+
|[BN_CTX_free called before BN_CTX_end](./cpp/src/docs/crypto/BnCtxFreeBeforeEnd.md)|Detects BN_CTX_free called before BN_CTX_end, which violates the required lifecycle|error|medium|
33+
|[Unbalanced BN_CTX_start and BN_CTX_end pair](./cpp/src/docs/crypto/UnbalancedBnCtx.md)|Detects if one call in the BN_CTX_start/BN_CTX_end pair is missing|warning|medium|
3234
|[Crypto variable initialized using static key](./cpp/src/docs/crypto/StaticKeyFlow.md)|Finds crypto variables initialized using static keys|error|high|
3335
|[Crypto variable initialized using static password](./cpp/src/docs/crypto/StaticPasswordFlow.md)|Finds crypto variables initialized using static passwords|error|high|
3436
|[Crypto variable initialized using weak randomness](./cpp/src/docs/crypto/WeakRandomnessTaint.md)|Finds crypto variables initialized using weak randomness|error|high|
@@ -46,9 +48,10 @@ codeql database analyze database.db --format=sarif-latest --output=./tob.sarif -
4648
| Name | Description | Severity | Precision |
4749
| --- | ----------- | :----: | :--------: |
4850
|[Async unsafe signal handler](./cpp/src/docs/security/AsyncUnsafeSignalHandler/AsyncUnsafeSignalHandler.md)|Async unsafe signal handler (like the one used in CVE-2024-6387)|warning|high|
51+
|[Decrementation overflow when comparing](./cpp/src/docs/security/DecOverflowWhenComparing/DecOverflowWhenComparing.md)|This query finds unsigned integer overflows resulting from unchecked decrementation during comparison.|error|high|
52+
|[Find all problematic implicit casts](./cpp/src/docs/security/UnsafeImplicitConversions/UnsafeImplicitConversions.md)|Find all implicit casts that may be problematic. That is, casts that may result in unexpected truncation, reinterpretation or widening of values.|error|high|
4953
|[Invalid string size passed to string manipulation function](./cpp/src/docs/security/CStrnFinder/CStrnFinder.md)|Finds calls to functions that take as input a string and its size as separate arguments (e.g., `strncmp`, `strncat`, ...) and the size argument is wrong|error|low|
5054
|[Missing null terminator](./cpp/src/docs/security/NoNullTerminator/NoNullTerminator.md)|This query finds incorrectly initialized strings that are passed to functions expecting null-byte-terminated strings|error|high|
51-
|[Unsafe implicit integer conversion](./cpp/src/docs/security/UnsafeImplicitConversions/UnsafeImplicitConversions.md)|Finds implicit integer casts that may overflow or be truncated, with false positive reduction via Value Range Analysis|warning|low|
5255

5356
### Go
5457

@@ -63,7 +66,7 @@ codeql database analyze database.db --format=sarif-latest --output=./tob.sarif -
6366
| Name | Description | Severity | Precision |
6467
| --- | ----------- | :----: | :--------: |
6568
|[Invalid file permission parameter](./go/src/docs/security/FilePermsFlaws/FilePermsFlaws.md)|Finds non-octal (e.g., `755` vs `0o755`) and unsupported (e.g., `04666`) literals used as a filesystem permission parameter (`FileMode`)|error|medium|
66-
|[Missing MinVersion in tls.Config](./go/src/docs/security/MissingMinVersionTLS/MissingMinVersionTLS.md)|This rule finds cases when you do not set the `tls.Config.MinVersion` explicitly for servers. By default version 1.0 is used, which is considered insecure. This rule does not mark explicitly set insecure versions|error|medium|
69+
|[Missing MinVersion in tls.Config](./go/src/docs/security/MissingMinVersionTLS/MissingMinVersionTLS.md)|Finds uses of tls.Config where MinVersion is not set and the project's minimum Go version (from go.mod) indicates insecure defaults: Go < 1.18 for clients or Go < 1.22 for servers. Does not mark explicitly set versions (including explicitly insecure ones).|error|medium|
6770
|[Trim functions misuse](./go/src/docs/security/TrimMisuse/TrimMisuse.md)|Finds calls to `string.{Trim,TrimLeft,TrimRight}` with the 2nd argument not being a cutset but a continuous substring to be trimmed|error|low|
6871

6972
### Java-kotlin
@@ -72,7 +75,7 @@ codeql database analyze database.db --format=sarif-latest --output=./tob.sarif -
7275

7376
| Name | Description | Severity | Precision |
7477
| --- | ----------- | :----: | :--------: |
75-
|[Recursive functions](./java-kotlin/src/docs/security/Recursion/Recursion.md)|Detects recursive calls|warning|low|
78+
|[Recursive functions](./java-kotlin/src/docs/security/Recursion/Recursion.md)|Detects possibly unbounded recursive calls|warning|low|
7679

7780
## Query suites
7881

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Decrementation overflow when comparing
2+
Finds unsigned integer overflow issues with the following heuristic: \* variable is compared to 0 and decremented \* variable is used after the comparison and decrementation In such cases it is likely that the decrementation was not expected.
3+
4+
You can read about a real-world vulnerability here: https://github.com/trailofbits/exploits/tree/main/obts-2025-macos-lpe
5+
6+
7+
## Recommendation
8+
Move the decrementation outside of comparison and/or add explicit checks for overflows.
9+
10+
11+
## Example
12+
13+
```c
14+
#include <stdio.h>
15+
#include <stdint.h>
16+
#include <stdlib.h>
17+
#include <string.h>
18+
19+
// from https://github.com/apple-oss-distributions/Libinfo/blob/9fce29e5c5edc15d3ecea55116ca17d3f6350603/lookup.subproj/mdns_module.c#L1033C1-L1079C2
20+
char* _mdns_parse_domain_name(const uint8_t *data, uint32_t datalen)
21+
{
22+
int i = 0, j = 0;
23+
uint32_t domainlen = 0;
24+
char *domain = NULL;
25+
26+
if ((data == NULL) || (datalen == 0)) return NULL;
27+
28+
while (datalen-- > 0)
29+
{
30+
uint32_t len = data[i++];
31+
domainlen += (len + 1);
32+
domain = reallocf(domain, domainlen);
33+
34+
if (domain == NULL) return NULL;
35+
36+
if (len == 0) break; // DNS root (NUL)
37+
38+
if (j > 0)
39+
{
40+
domain[j++] = datalen ? '.' : '\0';
41+
}
42+
43+
while ((len-- > 0) && (0 != datalen--))
44+
{
45+
if (data[i] == '.')
46+
{
47+
/* special case: escape the '.' with a '\' */
48+
domain = reallocf(domain, ++domainlen);
49+
if (domain == NULL) return NULL;
50+
51+
domain[j++] = '\\';
52+
}
53+
54+
domain[j++] = data[i++];
55+
}
56+
}
57+
58+
domain[j] = '\0';
59+
60+
return domain;
61+
}
62+
63+
int main() {
64+
const uint16_t datalen = 128;
65+
uint8_t data[datalen] = {};
66+
memcpy(data, "\x04quildu\x03xyz\x00", 11);
67+
_mdns_parse_domain_name(data, datalen);
68+
}
69+
70+
```
71+
The `datalen` variable may overflow to UINT_MAX given a specific input.
72+

0 commit comments

Comments
 (0)