doc: add threat model to SECURITY.md (security goals, reporting policy) #2002

pull theStack wants to merge 1 commits into bitcoin-core:master from theStack:doc-add_threat_model_to_security_md changing 2 files +114 −2
  1. theStack commented at 2:02 PM on November 16, 2026: contributor

    Add a "Threat Model" section to SECURITY.md that describes the security goals of the library and the resulting vulnerability reporting policy, i.e. which issues should be reported privately and which can be handled as regular public issues. Link it from README.md and CONTRIBUTING.md.

    So far, the security goals of the library were only documented implicitly, spread over the README, API docs and past review discussions. Writing them down in one place should help contributors, reviewers and reporters to decide what counts as a vulnerability and how to report it.

    A further motivation is automated LLM-based vulnerability finding (e.g. Bitcoin Red Team, Project Loupe, and Anthropic's OSS scanner program, in whch we will enroll): such programs need a written definition of what is in scope and what is considered a security issue, in order to produce relevant findings and to route them to the right channel (private report vs. public issue).

    The tested configurations and build modes listed in the reporting policy reflect what CI currently covers and need to be kept in sync with it.

    Thanks to real-or-random and sipa for discussions and input. Further feedback is highly appreciated, in particular on the reporting matrix, which in its current state could be replaced by a few sentences, since the columns only differ in one row.

  2. l0rinc commented at 2:06 PM on November 16, 2026: contributor
  3. real-or-random commented at 2:29 PM on November 16, 2026: contributor

    Are there plans to enroll to https://github.com/anthropics/oss-scanner, similarly to anthropics/oss-scanner#1080 (previous attempt at anthropics/oss-scanner#94)?

    yes, this is our primary (but not only) motivation

  4. real-or-random added the label assurance on Nov 16, 2026
  5. real-or-random added the label meta/development on Nov 16, 2026
  6. jonatack commented at 8:19 PM on November 16, 2026: member

    ACK

    No strong opinion on the reporting matrix vs prose. Perhaps scanners may understand prose better than the matrix. Sample diff for prose:

    <details><summary>diff</summary><p>

    -| Violated security goal | Tested production builds | Other builds |
    -|------------------------------------------|:------------------------:|:------------:|
    -| Cryptographic correctness<sup>1)</sup> | S | S |
    -| Robustness and availability<sup>1)</sup> | S | S |
    -| Side-channel resistance | S | P |
    -| Clearing of secret data<sup>2)</sup> | P | P |
    -
    -<sup>1)</sup> If such an issue turns out to be caused by a compiler bug, it may be resolved in the compiler rather than in the library.
    -
    -<sup>2)</sup> P because exploiting leftover secret data requires a separate memory disclosure (the later memory reader in 1.3), and the protection is best-effort (see 2.4).
    +Violations of cryptographic correctness or robustness and availability are S on all in-scope builds. If such an issue turns out to be caused by a compiler bug, it may be resolved in the compiler rather than in the library.
    +
    +Side-channel resistance violations are S on tested production builds and P on other builds.
    +
    +Violations of the secret-clearing goal are always P. Exploiting leftover secret data requires a separate memory disclosure (the later memory reader in 1.3), and the protection is best-effort (see 2.4).
    

    </p></details>

  7. in CONTRIBUTING.md:21 in dbf1b76df4
      17 | @@ -18,6 +18,7 @@ Contributors are recommended to provide the following in addition to the new cod
      18 |      If the specification contains pseudocode, a reference implementation or test vectors, these can be used to compare with the proposed libsecp256k1 code.
      19 |  * **Security Arguments:**
      20 |      In addition to a defining the security goals, it should be argued that the new functionality meets these goals.
      21 | +    The general security goals of the library are described in the [threat model](SECURITY.md#threat-model).
    


    real-or-random commented at 10:22 AM on November 17, 2026:

    I suggest not adding this sentence. The text here was meant to say "before we add protocol X (e.g., ellswift), we need to be sufficiently confident that X is a secure protocol". That's a protocol-layer thing and can be achieved via security proofs etc. But the threat model text added in this PR is not about X being secure. It's about X being implemented securely in the library.

  8. in README.md:59 in dbf1b76df4
      55 | @@ -56,7 +56,7 @@ Implementation details
      56 |    * Use secp256k1's efficiently-computable endomorphism to split the P multiplicand into 2 half-sized ones.
      57 |  * Point multiplication for signing
      58 |    * Use a precomputed table of multiples of powers of 16 multiplied with the generator, so general multiplication becomes a series of additions.
      59 | -  * Intended to be completely free of timing sidechannels for secret-key operations (on reasonable hardware/toolchains)
      60 | +  * Intended to be completely free of timing sidechannels for secret-key operations (on reasonable hardware/toolchains). See the [threat model](SECURITY.md#threat-model) for the precise goals.
    


    real-or-random commented at 10:23 AM on November 17, 2026:
      * Intended to be completely free of timing sidechannels for secret-key operations (on [reasonable hardware/toolchains](SECURITY.md#threat-model)).
    

    may be just as good and a bit shorter (but no strong opinion)

  9. in README.md:174 in dbf1b76df4
     170 | @@ -171,7 +171,7 @@ To create a CSV file for the benchmark result :
     171 |  Reporting a vulnerability
     172 |  ------------
     173 |  
     174 | -See [SECURITY.md](SECURITY.md)
     175 | +See [SECURITY.md](SECURITY.md) for how to report a vulnerability, and for the threat model, which describes the security goals of the library and which issues should be reported privately.
    


    real-or-random commented at 10:26 AM on November 17, 2026:
    See [SECURITY.md](SECURITY.md) for how to report a vulnerability, including guidelines on which issues we prefer to be reported privately.
    
  10. in SECURITY.md:23 in dbf1b76df4
      14 | @@ -13,3 +15,120 @@ The following keys may be used to communicate sensitive information to developer
      15 |  | Sebastian Falbesoner | 6A8F 9C26 6528 E25A EB1D  7731 C237 1D91 CB71 6EA7 |
      16 |  
      17 |  You can import a key by running the following command with that individual’s fingerprint: `gpg --keyserver hkps://keys.openpgp.org --recv-keys "<fingerprint>"` Ensure that you put quotes around fingerprints containing spaces.
      18 | +
      19 | +## Threat Model
      20 | +
      21 | +### 1. Scope and assumptions
      22 | +
      23 | +This section describes the threat model of libsecp256k1: the assumed attacker model, the security goals of the library, and the resulting vulnerability reporting policy.
    


    real-or-random commented at 10:35 AM on November 17, 2026:

    Not sure how to phrase this best (your LLM will know) but It would be nice to clarify here what I said above: what this describes is about attacks on the implementation and not protocol level attacks. Of course, if someone discovers a protocol-level issue, we still want to know about it, and the same classification rules should apply.

  11. in SECURITY.md:27 in dbf1b76df4
      22 | +
      23 | +This section describes the threat model of libsecp256k1: the assumed attacker model, the security goals of the library, and the resulting vulnerability reporting policy.
      24 | +
      25 | +#### 1.1 Covered code and versions
      26 | +
      27 | +In scope is the library itself (`src/` and `include/`, excluding the items below) in the latest release and on the `master` branch, including all modules and configuration options that do not require `--enable-experimental` (Autotools) or `-DSECP256K1_EXPERIMENTAL=ON` (CMake). Currently, the only experimental option is the ARM32 assembly implementation.
    


    real-or-random commented at 10:38 AM on November 17, 2026:

    I think we want reports for experimental code. Experimental so far meant "we're not entirely confident about the security" and not "we merged it with known vulnerabilities." So I think this is exactly the stage where we want reports.

    (ARM32 has been experimental for so long, I assume some people run it in production. I'm still in favor of not having any further experimental features in the futures. But that's a separate discussion.)

  12. in SECURITY.md:35 in dbf1b76df4
      30 | +
      31 | +#### 1.2 Secret data
      32 | +
      33 | +Secret data means:
      34 | +
      35 | +- Secret keys, including keypair objects.
    


    real-or-random commented at 10:43 AM on November 17, 2026:
    - Secret keys, including inside keypair objects.
    
  13. in SECURITY.md:39 in dbf1b76df4 outdated
      34 | +
      35 | +- Secret keys, including keypair objects.
      36 | +- Secret nonces and the randomness used to derive them, such as the auxiliary randomness for signing and the MuSig2 session randomness.
      37 | +- Shared secrets, such as ECDH results.
      38 | +- Other inputs and outputs that the API documents as secret.
      39 | +- Intermediate values derived from any of the above that are not intended to be public.
    


    real-or-random commented at 10:44 AM on November 17, 2026:
    - Other inputs and outputs that the API documents as secret.
    - Anything else that a user can reasonably expect to be secret.
    - Intermediate values derived from any of the above that are not intended to be public.
    

    I agree that's fuzzy but I tend to err on the safe side here. If we get over-reporting, this is rather a sign that our API docs can be improved.

  14. in SECURITY.md:48 in dbf1b76df4
      43 | +#### 1.3 Attacker model
      44 | +
      45 | +The security goals assume attackers with the following capabilities:
      46 | +
      47 | +- **Input attacker:** supplies arbitrary data to any API function argument that takes external input, such as serialized public keys, signatures, messages and tweaks.
      48 | +- **Protocol attacker:** participates in a multi-party protocol, such as a malicious co-signer in MuSig2, and deviates arbitrarily from it.
    


    real-or-random commented at 11:57 PM on November 17, 2026:

    I'm not entirely sure about these. Yes, we want to include protocol-level attacks, but these descriptions don't add much clarity. The interesting question is, for example, what arguments are considered "external" concretely. To answer this, you need a formal security model, and we tend not to talk about it in the docs here. (I think I've seen libraries document this but that's also a bit questionable given the target audience. A comment that Schnorr sigs are supposed to SUF-CMA under rerandomizable keys may not be helpful to anyone but cryptographers, and they'll look up the papers anyway.)

    Also, both points are rather similar. A typical security game covers both, and the second bullet is subsumed by the first (contributions to a multi-party protocol are "external input".)

    I'm not exactly sure what the best thing here is but my current thinking is taking a step back and don't listing the attacker-capabilities concretely, because that list will always be fuzzy at this high level and also because it may make the impression that the list is meant to be complete. What about dropping this subsection, and moving specific points in it to more specific subsection. For example, we could have "Side-channel attacks" (or "Timing attacker" and "Memory reader attacks" etc.) and "Protocol-level attacks", the latter one clarifying that "Protocol-level and scheme-level vulnerabilities are in scope, even if these stem from issues in specifications, papers, etc."

    This leaves the generic definition of a vulnerability implicit and open for the reporter to judge: A vulnerability is whatever an attacker can exploit to do harm. (Now that I spelled it out that way, I tend to think that we can also this sentence, or a variant of it, explicit). The subsections then simply make this more concrete for specific kinds of attacks.

  15. in SECURITY.md:75 in dbf1b76df4
      70 | +
      71 | +Valid and adversarial inputs within the documented API contract must not cause crashes, memory corruption, undefined behavior or disproportionate resource consumption.
      72 | +
      73 | +Violations of documented API preconditions are out of scope, such as passing invalid pointers or uninitialized objects, modifying opaque objects other than through the API, and violating the thread-safety rules for context objects. The library only performs lightweight sanity checks on its objects, such as checking magic bytes. Expensive consistency checks, such as checking that an internal group element lies on the curve, are not intended. Externally supplied inputs must nevertheless be validated as required by the API.
      74 | +
      75 | +Aborting through the illegal argument callback on a detected API violation is intended. Aborting through the error callback is intended if the cause lies outside the library, such as memory exhaustion, hardware failure, miscompilation or memory corruption by the application. If valid or adversarial inputs can trigger the error callback while the API is used as documented, this is a bug.
    


    real-or-random commented at 11:31 AM on November 18, 2026:
    Aborting through the illegal argument callback on a detected API violation is intended. Aborting through the error callback is intended if the cause lies outside the library, such as memory exhaustion, hardware failure, miscompilation or memory corruption by the application. If valid or adversarial inputs can trigger the error callback while the API is used as documented, this is a vulnerability.
    

    In general, we should aim for consistent language here, i.e., if we talk about the same thing, call it the same thing, e.g., always call it a "vulnerability" or a "security bug". Which one doesn't matter but we should pick one and use it everywhere. (If I could people only give you one low-level advice for technical writing, I think that would be it. ;))

  16. in SECURITY.md:77 in dbf1b76df4
      72 | +
      73 | +Violations of documented API preconditions are out of scope, such as passing invalid pointers or uninitialized objects, modifying opaque objects other than through the API, and violating the thread-safety rules for context objects. The library only performs lightweight sanity checks on its objects, such as checking magic bytes. Expensive consistency checks, such as checking that an internal group element lies on the curve, are not intended. Externally supplied inputs must nevertheless be validated as required by the API.
      74 | +
      75 | +Aborting through the illegal argument callback on a detected API violation is intended. Aborting through the error callback is intended if the cause lies outside the library, such as memory exhaustion, hardware failure, miscompilation or memory corruption by the application. If valid or adversarial inputs can trigger the error callback while the API is used as documented, this is a bug.
      76 | +
      77 | +#### 2.3 Side-channel resistance
    


    real-or-random commented at 11:32 AM on November 18, 2026:

    This could be more specific to "No secret-dependent control flow or memory access", because it only deals with this, and reading data from memory (covered below) is also a side channel.

    On a higher level, I don't think that 2.3+2.4 add much over the related points in 1.3. I think these can be merged, and then 2.3+2.4 are more precise. 1.3 describes attacker capabilities but these are subsumed by our concrete well-defined goals in 2.3+2.4 already.

    With that in mind, maybe section 1 could go entirely, i.e., not sure if the distinction between 1 and 2 is still meaningful. Maybe a more meaningful structure can be found.

  17. in SECURITY.md:99 in dbf1b76df4
      94 | +|------------------|--------------|-----------------------|
      95 | +| Linux            | x86_64       | GCC, Clang            |
      96 | +| Linux            | i686         | GCC, Clang            |
      97 | +| Linux            | ARM32        | GCC                   |
      98 | +| Linux            | ARM64        | GCC, Clang            |
      99 | +| Linux            | s390x        | GCC                   |
    


    real-or-random commented at 11:50 AM on November 18, 2026:

    I'd exclude that one. It's tested but the test was added because s390x is big endian. I don't think (read: I seriously hope) anyone runs our code in production on a mainframe.

    If we remove it from the list, "tested" may not be the best term then. Maybe "tier 1" or "primary targets" something. (A goal is of course that "tier 1" is a subset of "tested")

  18. in SECURITY.md:108 in dbf1b76df4
     103 | +| Windows          | x86_64       | MSVC, clang-cl, MinGW |
     104 | +| Windows          | x86          | MSVC, MinGW           |
     105 | +
     106 | +The ARM32 row refers to the generic C implementation. The ARM32 assembly implementation is experimental and therefore out of scope (see 1.1).
     107 | +
     108 | +Unreleased compiler versions such as development snapshots, bare-metal targets and all platforms not listed are other configurations. The list may change as platform and compiler support evolves. Automated constant-time tests cover only some of these configurations and parts of the API, and are not a proof of constant-time behavior. Side-channel issues in production builds are nevertheless S (see 3.3) in all tested configurations.
    


    real-or-random commented at 11:51 AM on November 18, 2026:

    It's nice that unreleased compilers are included and we should emphasize this. They're interested for miscompilations and for new "optimizations" that kill our constant-time efforts.

  19. in SECURITY.md:117 in dbf1b76df4 outdated
     112 | +A *production build* uses `-O1` (or `-O`) to `-O3` (the build system default is `-O2`), or `/O2` with MSVC, without sanitizers, coverage or other instrumentation. Builds with `-O0`, `-Og`, `-Os`, `-Oz`, `-Ofast`, `/Od` or `/O1` are not production builds. Size-optimized builds (`-Os`, `-Oz`, `/O1`) are excluded because they make it more likely that the compiler turns branch-free code into secret-dependent branches. CI runs the automated constant-time tests mainly at `-O2`; `-O1` and `-O3` are covered only on Linux x86_64 (`-O3` only with Clang).
     113 | +
     114 | +#### 3.3 Reporting matrix
     115 | +
     116 | +- **S (security issue):** report privately as described in [Reporting a Vulnerability](#reporting-a-vulnerability).
     117 | +- **P (public issue):** report as a regular public issue or open a pull request. These are handled as regular bugs, not confidentially.
    


    real-or-random commented at 11:55 AM on November 18, 2026:

    No matter what terms are, they're should be two or three categories:

    • vulnerabilites that are bad enough so they should be handled in secret
    • vulnerabilites that are low impact and can be handled in public. these should only be the ones clearly listed here in this document.
    • regular bugs; those can always be handled in public
  20. in SECURITY.md:132 in dbf1b76df4
     127 | +
     128 | +<sup>1)</sup> If such an issue turns out to be caused by a compiler bug, it may be resolved in the compiler rather than in the library.
     129 | +
     130 | +<sup>2)</sup> P because exploiting leftover secret data requires a separate memory disclosure (the later memory reader in 1.3), and the protection is best-effort (see 2.4).
     131 | +
     132 | +The matrix applies to issues with a plausible security impact, i.e., issues that an attacker as described in 1.3 can trigger or exploit, or that can lead to disclosure of secret data or to incorrect results in honest use. Issues without such an impact, such as undefined behavior without any observable effect or documentation errors that do not lead to insecure use, are always P. If in doubt, report privately.
    


    real-or-random commented at 11:56 AM on November 18, 2026:

    "issues with a plausible security impact" -> vulnerabilities (or whatever term we pick)

    "If in doubt, report privately.": Agreed, this is the an important rule.

  21. real-or-random commented at 11:58 AM on November 18, 2026: contributor

    I have a lot of text suggestions but let me stress that I mostly agree with the contents.

  22. doc: add threat model to SECURITY.md (security goals, reporting policy)
    Add a section to SECURITY.md that describes the threat model of the
    library, i.e. its security goals and the resulting vulnerability
    reporting policy. Link it from README.md.
    f4757e12da
  23. theStack force-pushed on Nov 20, 2026
  24. theStack commented at 5:47 PM on November 20, 2026: contributor

    @real-or-random: Thanks for the detailed review, much appreciated! :pray: I've addressed most of your suggestions and changed the structure a bit accordingly (see e.g. $ git diff --word-diff dbf1b76d f4757e12):

    • the "attacker model" section is removed, the relevant parts moved into the goals subsections below
    • added a clarification that this document states the security goals of the implementation, not of the specific schemes/protocols, but that the latter still fall into the reporting policy (decided to make this explicit rather early, as suggested in #2002 (review))
    • there is now a definition section, defining both "vulnerability" and "secret data"
    • the "non-goals" moved from the first to the second section, after the goals (that wasn't part of your review, but I find it clearer there)
    • renamed "tested configurations/builds" to "primary configurations/builds", removed s390x from the list
    • experimental modules and config options are now explicitly in scope (previously out of scope)
    • removed the link from CONTRIBUTING.md

    Let me know if I forgot anything or there are further suggestions.

  25. theStack renamed this:
    doc: add threat model to SECURITY.md (attacker model, security goals, reporting policy)
    doc: add threat model to SECURITY.md (security goals, reporting policy)
    on Nov 20, 2026

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/secp256k1. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-12-02 10:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me