Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

c_str() / data() lifetime issues in generated targets #164

Open
oliverchang opened this issue Mar 18, 2024 · 1 comment
Open

c_str() / data() lifetime issues in generated targets #164

oliverchang opened this issue Mar 18, 2024 · 1 comment
Labels
bug Something isn't working prompt-engineering

Comments

@oliverchang
Copy link
Collaborator

Some generated targets have the following bad pattern:

const char *server = stream.ConsumeRemainingBytesAsString().c_str();

The std::string returned by FuzzedDataProvider instantly goes out of scope, leading to UAF on use of the pointer.

@oliverchang
Copy link
Collaborator Author

We can potentially detect instances of this (and potentially more general issues) by checking if the ASan-reported free stack has LLVMFuzzerTestOneInput at the top, which indicates the freeing happened in the target.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working prompt-engineering
Projects
None yet
Development

No branches or pull requests

1 participant