T3MP3ST public launch build
This commit is contained in:
1 parent
972247b881
commit
184c7d4e59
1589 files changed
+57150
-506
No files matched your search
@@ -0,0 +1,28 @@
|
||||
cve: POSTCUT-004
|
||||
alias: Protobuf decoder OOB read — declared length not validated against buffer
|
||||
cwe_primary: CWE-125
|
||||
cwe_acceptable: [CWE-125, CWE-130, CWE-787, CWE-119, CWE-789]
|
||||
target_file: source.c
|
||||
vuln_lines: [37, 38, 39, 40, 41, 42, 43]
|
||||
severity: high
|
||||
vuln_class: out_of_bounds_read
|
||||
exploit_pattern_regex: '(declared.*length|length.*field|missing.*bounds|memcpy.*end|p\s*\+\s*declared|attacker.*controlled.*length|over[- ]read)'
|
||||
must_mention_any:
|
||||
- declared length
|
||||
- missing bounds check
|
||||
- no validation
|
||||
- end pointer
|
||||
- memcpy
|
||||
- over-read
|
||||
- out-of-bounds read
|
||||
- p + declared_len
|
||||
- buf_len
|
||||
points: 30
|
||||
memorization_resistant: true
|
||||
notes: |
|
||||
Synthetic — novel pattern. declared_len comes from the wire varint and is
|
||||
used directly as memcpy length and malloc size. Nothing checks
|
||||
declared_len against (end - p). Attacker sets declared_len = 0xFFFFFFFF →
|
||||
malloc small (with overflow on +1) and/or memcpy reads way past buf_end,
|
||||
disclosing adjacent heap. Also potential integer overflow on malloc(len+1)
|
||||
when len == SIZE_MAX.
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* pb_decode_string — protobuf-like string decoder.
|
||||
* Pre-fix; internal RPC layer.
|
||||
*
|
||||
* Wire format: <varint length> <length bytes of data>
|
||||
* Caller passes a buffer; this writes the decoded length-prefixed string
|
||||
* into a heap buffer allocated based on the wire-supplied length.
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
static int read_varint(const uint8_t **p, const uint8_t *end, uint64_t *out) {
|
||||
uint64_t v = 0; int shift = 0;
|
||||
while (*p < end) {
|
||||
uint8_t b = *(*p)++;
|
||||
v |= ((uint64_t)(b & 0x7f)) << shift;
|
||||
if ((b & 0x80) == 0) { *out = v; return 0; }
|
||||
shift += 7;
|
||||
if (shift > 63) return -1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Returns a newly malloc'd copy of the decoded string. *out_len gets length. */
|
||||
char *pb_decode_string(const uint8_t *buf, size_t buf_len, size_t *out_len) {
|
||||
const uint8_t *p = buf, *end = buf + buf_len;
|
||||
|
||||
uint64_t declared_len = 0;
|
||||
if (read_varint(&p, end, &declared_len) != 0) return NULL;
|
||||
|
||||
/* allocate +1 for nul terminator */
|
||||
char *s = (char *)malloc((size_t)declared_len + 1);
|
||||
if (s == NULL) return NULL;
|
||||
|
||||
/* copy declared_len bytes from the wire */
|
||||
memcpy(s, p, (size_t)declared_len);
|
||||
s[declared_len] = '\0';
|
||||
|
||||
*out_len = (size_t)declared_len;
|
||||
return s;
|
||||
}
|
||||
Reference in new issue
Block a user