🌐
GitHub
github.com › hardik05 › Damn_Vulnerable_C_Program
GitHub - hardik05/Damn_Vulnerable_C_Program: An example C program which contains vulnerable code for common types of vulnerabilities. It can be used to show fuzzing concepts. · GitHub
[Fuzzing with libAFL]Fuzzing Damn Vulnerable C Program with libAFL forkserver fuzzer -> https://www.youtube.com/watch?v=ad_4zroiS_g · [Fuzzing with libAFL] Using shared memory mode with libAFL forkserver fuzzer -> https://www.youtube.com/watch?v=GXD_qkISyfY ... [Fuzzing with AFLplusplus] Installing AFLPlusplus and fuzzing a simple C program -> https://www.youtube.com/watch?v=9wRVo0kYSlc · [Fuzzing with AFLplusplus] How to fuzz a binary with no source code on Linux in persistent mode -> https://www.youtube.com/watch?v=LGPJdEO02p4
Starred by 721 users
Forked by 184 users
Languages   Rust 70.7% | Makefile 25.2% | LLVM 3.1% | C 1.0% | C++ 0.0% | M4 0.0%
🌐
GitHub
github.com › conikeec › seeve
GitHub - conikeec/seeve: A set of vulnerable C code snippets (with mapped CVEs)
A set of vulnerable C code snippets (with mapped CVEs) - conikeec/seeve
Starred by 78 users
Forked by 63 users
Languages   C 88.8% | Makefile 11.2% | C 88.8% | Makefile 11.2%
Discussions

vulnerability - Some vulnerable projects in C or C++ for a lecture? - Information Security Stack Exchange
Closed 6 years ago. ... I'm looking for some real projects which have stack overflow vulnerabilities. The important thing is, I am going to teach finding the vulnerabilities and the way of fixing them by these examples. So, the vulnerabilities should be simple to find and simple to patch. Do you know any source code ... More on security.stackexchange.com
🌐 security.stackexchange.com
May 24, 2017
security - Find the vulnerability in the C program - Stack Overflow
If name is not null terminated, ... calling code. ... @Jabberwocky: As stated, the context is not clear. It is possible for this routine to guard somewhat against being passed a string that is not null-terminated, and that could be made a requirement of the routine. To be fair, doing that thoroughly would require access to some mechanism for detecting unmapped memory. But vulnerability analysis goes ... More on stackoverflow.com
🌐 stackoverflow.com
Security vulnerabilities in fairly simple c code - Stack Overflow
Debugging inside the kernel was ... just choose a number at random, start writing into it and everything runs fine. 2012-12-21T14:12:15.457Z+00:00 ... @UmNyobe if you allocate a large piece of memory and read from file in that memory more than the file actually has fread() will return EOF and the code will return NULL it won't write beyond the buffer, how's is that considered a vulnerability ... More on stackoverflow.com
🌐 stackoverflow.com
Buffer Overflow Vulnerability C Code
I'm assuming this is a copy paste of your homework, so, did you try to do it and have an specific question? Are your stuck somewhere? More on reddit.com
🌐 r/C_Programming
6
0
February 28, 2023
🌐
Tenouk
tenouk.com › Bufferoverflowc › Bufferoverflow6.html
The vulnerable and the exploit program examples using C programming language based on the SUID/GUID programs on Linux opensource machine with Intel microprocessor
In our exploit example we are going to overflow the stack using a SUID program. In this exploit we as normal user are going to spawn a local root shell by overflowing the program owned by root. The vulnerable program used is shown below. This is a SUID program.
🌐
Code Intelligence
code-intelligence.com › blog › most-dangerous-vulnerabilities-cwes-in-c-2025
Top Six Most Dangerous Vulnerabilities in C and C++
2 related CVEs are actively exploited in the wild and listed in the Known Exploited Vulnerabilities (KEV) catalog. Example of Improper Restriction of Operations within the Bounds of a Memory Buffer:
🌐
Medium
medium.com › @capturethebugs › common-c-vulnerabilities-56ffad22581e
Common C Vulnerabilities. Introduction | by Capture The Bug | Medium
September 18, 2022 - ... #include <stdio.h>int main () { char str[50]; printf("Enter a string : "); gets(str); printf("You entered: %s", str); return(0); } Mitigation: Instead of gets(), you can use the fgets() function.
🌐
Snyk
snyk.io › blog › unintimidating-intro-to-c-cpp-vulnerabilities
An unintimidating introduction to the dark arts of C/C++ vulnerabilities | Snyk
April 15, 2022 - These defense mechanisms depend ... your code. We have mechanisms like ASLR (address space layout randomization), stack canaries, and DEP (data execution prevention), to name a few. All are aimed at preventing memory corruption bugs like buffer overflow. During runtime, failing any of these mechanisms will cause the OS to stop execution and throw a SEGFAULT, making the whole exploitation process less straightforward. I’d like to give one example of such a vulnerability and its ...
🌐
ResearchGate
researchgate.net › figure › An-example-of-a-vulnerable-C-program_fig4_365348667
An example of a vulnerable C program | Download Scientific Diagram
Another approach to source code representation combining control flow, data dependencies, and syntax structure was proposed by Xinghang · Lv et al. (2023). This approach aimed to detect buffer overflow vulnerabilities in the C and C++ languages.
🌐
Medium
int0x33.medium.com › day-49-common-c-code-vulnerabilities-and-mitigations-7eded437ca4a
Day 49: Common C Code Vulnerabilities and Mitigations | by int0x33 | Medium
February 17, 2019 - Uncontrolled format string is a vulnerability category which can cause information leakage and overwriting of memory. The following functions are also vulnerable: printf, fprintf, sprintf and snprintf.
Find elsewhere
🌐
Cern
security.web.cern.ch › recommendations › en › codetools › c.shtml
C Programming Vulnerabilities - Computer Security - CERN
Now, this code, if compiled with the -mpreferred-stack-boundary=2 option (on a 32-bit platform; on 64-bit things work slightly differently, but the code still is vulnerable!), can yield interesting results. If called with ./FormatString %s, it will print the secret string. $ gcc -mpreferred-stack-boundary=2 FormatString.c -o FormatString $ ./FormatString %s This is a secret! $ Note: the -mpreferred-stack-boundary=2 option is in no way necessary to cause information leakage and not setting it does not make your code more secure by any means. It just allows for a simpler and more straight forward example.
🌐
ResearchGate
researchgate.net › figure › C-code-snippet-showing-vulnerable-line-of-code_fig2_274494811
C code snippet showing vulnerable line of code. | Download Scientific Diagram
Download scientific diagram | C code snippet showing vulnerable line of code. from publication: Buffer overflow patching for C and C++ programs | The presence of buffer overflow (BOF) vulnerabilities in programs hampers essential security objectives such as confidentiality, integrity and availability.
🌐
GeeksforGeeks
geeksforgeeks.org › c language › security-issues-in-c-language
Security issues in C language - GeeksforGeeks
August 6, 2025 - Observed CVEs are CVE-1999-0067, CVE-2019-12921. ... Ensure that all external commands called from the program are statically created. Use library calls rather than external processes to recreate the desired functionality.
🌐
GitHub
github.com › fuzzstati0n › fuzzgoat
GitHub - fuzzstati0n/fuzzgoat: A vulnerable C program for testing fuzzers. · GitHub
This C program has been deliberately backdoored with several memory corruption bugs to test the efficacy of fuzzers and other analysis tools. Each vulnerability is clearly commented in fuzzgoat.c. Under input-files/ are files to trigger each vulnerability. CAUTION: Do not copy any of this code - ...
Starred by 208 users
Forked by 75 users
Languages   C 99.6% | Makefile 0.4%
Top answer
1 of 3
3

Create a large file such that reading row and cols are both negatives. rasterBytes = pixBytes * rows * cols is positive so everything will be fine till p = img->raster;. But at this point you have two infinite loops, and the program may overwrite the heap.

Another attack is to set up row and cols such that they have different sign. You can choose either value to be -1, while the other is large enough to read the data you want. The allocation

  img->raster = (void*)malloc(rasterBytes);

will fail, which lead img->raster to point to NULL. Which means

 fread(p, pixBytes, 1, fp) < 1

will try to read the content of the file to kernel memory. If this code is executed in kernel mode, depending of the system (let say old unix which doesn use memory segment), then you will overwrite the content of the kernel memory with the content of the file. A kernel which doesn use memory segment rely not on segmentation faults but on page faults (a virtual address which doesnt have any real page assigned to it). The issue is that there are virtual memory designs such that the first real pages are directly assigned to the kernel pages. Ie kernel virtual address 0x0 is correspond to the real memory at 0x0 and is perfectly valid (inside the kernel).

EDIT: In both of those cases, the goal of the attacker is to inject the content of the input file (which is totally under his control) in a region of memory he should not have access to, while not being able to modify the function read_ppm().

2 of 3
0

There is also the fact that this allocation is not checked for success. Could result in a DoS.

img->raster = (void*)malloc(rasterBytes);
🌐
Software Engineering Institute
sei.cmu.edu › documents › 3739 › 2005_017_101_52657.pdf pdf
© 2005 Carnegie Mellon University Secure Coding in C and C++
A software vulnerability may result when a program · evaluates an integer to an unexpected value. © 2005 Carnegie Mellon University · 31 · Integer Security Example · 1. int main(int argc, char *argv[]) { 2. unsigned short int total; 3. total=strlen(argv[1])+ strlen(argv[2])+1; 4.
🌐
Cgisecurity
cgisecurity.com › 2011 › 03 › nist-publishes-50kish-vulnerable-code-samples-in-javacc-is-officially-krad.html
NIST publishes 50kish vulnerable code samples in Java/C/C++, is officially krad – CGISecurity.com
March 31, 2011 - NIST has published a fantastic project (its been out since late December, but I only just became aware of it) where they've created vulnerable code test cases for much of MITRE's CWE project in Java and c/c++. From the README
🌐
Reddit
reddit.com › r/c_programming › buffer overflow vulnerability c code
r/C_Programming on Reddit: Buffer Overflow Vulnerability C Code
February 28, 2023 -

Hi folks,

I have this c code:

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

int ssp(char * str)
{
    char buffer[100];
    strcpy(buffer,str);

    return 1;
}

int main(int argc, char **argv)
{
    char str[400];
    FILE * afile;

    afile = fopen("afile", "r");
           fread(str, sizeof(char), 400, afile);
    ssp(str);

    printf("Returned Properly\n");  

    return 1;
}

The program provided reads the contents of a file called `"afile"` into a character array called `str`, which can hold up to 400 characters. It then calls the `ssp` function and passes `str` as an argument.

The `ssp` function copies the contents of the `str` character array into a local character array called buffer. The `strcpy` function used to copy the string data does not perform any bounds checking, which can lead to buffer overflow vulnerabilities if the input string is longer than the buffer size.

However, the lack of bounds checking in the `strcpy` function in the `ssp` function can potentially lead to buffer overflow vulnerabilities if used in a larger program or in an environment with untrusted input data.

Could anyone please assist with a shellcode at the end of "afile" and then store the shellcode on the stack to run? Please...

🌐
LiU
ida.liu.se › ~TDDC90 › literature › slides › TDDC90_Vulnerabilities_II.pdf pdf
Vulnerabilities in C/C++ programs – Part II TDDC90 – Software Security
Non-memory-corruption vulnerabilities · So far, we have looked at bugs allowing attackers to overwrite control-data · for, e.g., arbitrary code execution or DoS · ▪Many dangerous types of bugs are not the result of buffer overflows or · other memory corruption errors: ▪Race conditions · ▪Out-of-bounds reads of data · 11 · Race conditions · A shared resource is changed between check and use · ▪Example: File system race conditions ·
🌐
We Live Security
welivesecurity.com › 2017 › 01 › 30 › examples-vulnerable-code-find
Some examples of vulnerable code and how to find them
January 30, 2017 - The above shows part of the vulnerable code on the University of Washington's IMAP server, which was corrected in 1998. We can see that it never checks the size of the data in mechanism before copying to tmp, which could result in a buffer overflow.