This document describes the policy followed by the libffi maintainers to handle bugs that may have a security impact. This includes determining if a bug has a security impact, reporting such bugs privately, and handling them through to public disclosure. This policy may evolve over time, so if you are reading this from a release tarball, please check the latest copy in the libffi repository for current reporting instructions.
libffi is a low-level runtime library. Its callers provide call interface descriptions (ffi_cif), function pointers, argument buffers, return-value buffers, and (for closures) user-supplied handler functions. libffi trusts its caller to:
A program that constructs CIFs, argument buffers, or function pointers from untrusted input is responsible for validating them before calling into libffi. Crashes, memory corruption, or undefined behavior resulting from a caller violating these contracts are caller bugs, not libffi vulnerabilities.
Within that threat model, libffi has security obligations of its own. When a caller uses the library correctly, libffi must not introduce memory corruption, leak information across calls, or compromise the executable memory it manages for closures. Bugs that break those obligations are in scope for this policy.
The following guidelines are used to decide whether a defect is treated as a security vulnerability. In every case, the question is whether libffi itself is the cause when it is used in a manner consistent with its documentation.
The following are generally not treated as security bugs:
libffi allocates executable trampolines so that runtime-generated closures can be called like ordinary C functions. On platforms that support it, libffi uses static trampolines, memfd_create, dual-mapping, or other mechanisms to keep writable and executable views of the trampoline memory separate.
Bugs that defeat the W^X guarantee on platforms where libffi advertises support for it — for example, by leaving a page both writable and executable, by exposing a writable alias to attacker-controllable data, or by emitting a trampoline that branches into caller-controlled memory — are security bugs.
On platforms where W^X enforcement is not available and libffi falls back to a writable-and-executable allocation (as documented), the absence of W^X is not itself a vulnerability. The documented fallback is a portability concession, and callers that need stronger guarantees should configure libffi to disable closures or run on a supported platform.
libffi contains hand-written assembly and ABI-specific C for each target. Bugs that corrupt memory, mishandle the stack, or skip required register saves in those backends are in scope when triggered by ABI-conforming input. Bugs that merely produce a wrong-but-non-corrupting result for an exotic-but-valid type combination are treated as ordinary correctness bugs unless the wrong result is itself a security exposure (for example, a silently truncated pointer that bypasses a caller's bounds check).
Hardening such as stack protectors, control-flow integrity, and PaX/MPROTECT interactions in the closure allocator are included to make exploitation of unrelated bugs more difficult. Failure of these countermeasures to stop exploitation of a different vulnerability is not, on its own, a security bug in libffi. The underlying vulnerability must still be fixed.
Please report suspected security vulnerabilities privately using GitHub's private vulnerability reporting at https://github.com/libffi/libffi/security/advisories/new.
Helpful information to include:
ffi_cif and call sequence), preferably as a standalone C program,If you cannot use GitHub's reporting flow, contact the maintainers listed in README.md directly. Please do not open a public GitHub issue, send a pull request, or post on a mailing list for an unfixed vulnerability until disclosure has been coordinated.
Routine correctness bugs, build failures, and questions should be filed as ordinary public issues at https://github.com/libffi/libffi/issues.
This section is aimed at maintainers.
When a report is received:
master, backport to the supported release branches, cut a release, and publish the advisory describing the affected versions, the impact, and the fix commits.Security bugs that affect released versions of libffi should normally receive a CVE identifier. CVE IDs can be requested via GitHub's security advisory workflow when publishing the advisory, or directly from a CVE Numbering Authority. Include the CVE identifier in the advisory, in the commit message of the fix, and in the release notes for the fixed release.