medium · M4 · MASVS-CODE-4 · PTKD-IOS-UNSAFE-C-STRING
Unsafe C string function (buffer overflow risk)
The binary imports an unbounded C string function (strcpy/strcat/sprintf/gets/stpcpy), which copies without a length check and is a classic stack/heap buffer overflow when the source is attacker-influenced.
How it is exploited
The binary imports an unbounded C string function (strcpy/strcat/sprintf/gets). When the source data is longer than the destination buffer, the copy overflows it. With attacker-controlled input this corrupts the stack or heap and, past the binary's mitigations, can lead to code execution.
Why it matters
Memory corruption and, in the worst case, remote or local code execution; at minimum a crash (denial of service).
How to fix it
- Replace strcpy/strcat/sprintf with the bounded strlcpy/strlcat/snprintf and always pass the destination size.
- Never use gets; read with a bounded API.
- If the symbol came from a static dependency, update it; verify the finding against your own code first.
Does your app have this?
PTKD checks your build or your source project for PTKD-IOS-UNSAFE-C-STRING and every other check in this knowledge base.
Scan your appReferences
Related checks (M4)
- Supabase function runs any SQL the caller sends
- Deep link URL loaded or opened without a host check (heuristic)
- Hybrid WebView may open any website inside the app
- Wildcard associated domain (universal-link hijack surface)
- Process execution via system()/exec/popen
- Hijackable custom URL-scheme deep link
- SQL built by joining request data into a string (text search)
- HTML rendered without sanitizing (dangerouslySetInnerHTML / innerHTML)