Technical Guide: AI Code Licence Risk

    GPL-2.0-only Apache-2.0 Compatibility for AI-Generated Code

    GPL-2.0-only code is generally treated as incompatible with distribution under Apache-2.0, because the two licences impose terms that cannot both be satisfied in one combined work. A coding assistant can emit a snippet that reproduces such code without any signal of its origin, and dependency-level scanning will not see it. A practical control process detects origin at the point of suggestion, decides to allow, redact or block, escalates ambiguous cases to human review, and keeps evidence of each decision. Counsel should review ambiguous cases.

    A practical control process

    1. 1

      Detect origin and licence

      Assess each suggestion for origin, licence and security context before it is presented for acceptance.

    2. 2

      Decide the outcome

      Apply internal policy to allow, redact or block. For an Apache-2.0 project, policy should state how GPL-2.0-only and unknown-licence matches are handled.

    3. 3

      Escalate ambiguity

      Route unclear or unknown origin to a named human approver, with counsel involved where the licence position is uncertain.

    4. 4

      Mark assistant-originated changes

      Carry the decision forward so reviewers see at commit and in CI which changes came from an assistant.

    5. 5

      Verify at release

      Check that third-party licence and copyright statements are retained wherever third-party code is legally incorporated.

    6. 6

      Retain the evidence

      Store the record of origin, decision and approver in access-controlled, tamper-evident form.

    Evaluating whether current controls address the risk

    • Can you show, for each merged change, whether a suggestion came from an assistant and which origin or licence checks ran?
    • Do controls act at the point of suggestion, or only in dependency scanning after merge?
    • What happens to a suggestion of ambiguous or unknown origin, and who decides?
    • Are decisions recorded with origin, outcome and approver, not only the final code?
    • Are decision records stored on a least-privilege basis, so only authorised people, tools and services can access them?
    • Do release artefacts retain third-party licence and copyright statements and attribution?

    Why GPL-2.0-only and Apache-2.0 conflict

    Two features of GPL-2.0-only drive most of the concern. The first is the word "only". Some GPL-2.0 projects grant the option to use a later version of the licence. GPL-2.0-only does not, so the code cannot be relicensed under GPL-3.0 terms, and that closes the route most often used to combine GPL code with Apache-2.0 code.

    The second is the interaction between licence terms. Apache-2.0 includes an express patent grant that can terminate for a licensee who brings certain patent litigation, and it carries attribution and notice conditions. GPL-2.0 forbids adding restrictions beyond its own terms to a combined work. The patent termination condition is commonly treated as such a restriction, which is why GPL-2.0-only code is generally considered incompatible with distributing a combined work under Apache-2.0.

    The relationship is also directional. Apache-2.0 code is generally treated as usable in GPL-3.0 projects, but that does not make GPL-3.0 code usable in an Apache-2.0 project, and it does not extend to GPL-2.0-only. The practical consequence for an Apache-2.0 project is that GPL-2.0-only material in the tree is a distribution problem, not only a documentation problem. These are general descriptions, not legal advice. Specific combinations and remediation choices need review by qualified counsel.

    How AI suggestions introduce the problem

    NIST AI 600-1 notes that if a generative AI system's training data included copyrighted material, outputs displaying instances of training data memorization could infringe copyright. For code, that means an assistant may emit a snippet that matches or closely resembles licensed source. The assistant does not attach the licence, and the engineer accepting the suggestion often cannot tell where it came from.

    This guide makes no claim about how often this happens, and no frequency figure should be assumed. The control question does not depend on the rate. A single unreviewed GPL-2.0-only snippet in an Apache-2.0 release creates the same distribution issue as a larger import.

    The Copyright Office has listed liability for infringing works generated using AI systems as an open area of inquiry, including whether outputs can implicate the right of reproduction or the derivative work right. These are posed as questions, not findings. Until they are settled, the sensible position is to treat ambiguous assistant output as a licence question that a person should resolve.

    Where dependency-level scanning stops working

    Software composition analysis is built around declared components: package manifests, lockfiles and known library versions. A snippet pasted from an assistant has no manifest entry and no declared licence. It looks like first-party code, so a dependency scan can pass while the repository contains code under an incompatible licence.

    NIST SP 800-218A does not distinguish between human-written and AI-generated source code, because all source code is assumed to need evaluation before use. That supports applying checks to assistant output at each stage where code moves, not only after merge.

    At suggestion time, a check can assess origin and licence context before the engineer sees the snippet, and it is the only stage where a block prevents the code from entering the editor at all. At pre-commit and in CI, checks can flag changes that came from an assistant and route them to review. At release, checks can confirm that required licence statements and notices are present in the artefacts. Each stage catches what earlier ones miss, and matching on similarity has inherent limits: modified, reformatted or partial copies can be harder to identify than verbatim ones. Layered checks with human escalation are more dependable than any single detector.

    Where Trussed fits

    Trussed enforces policy in the execution path of coding assistants. Code provenance supplies the origin, licence and security context of code, and policy is enforced at runtime, not reviewed after the fact. For an individual interaction or tool call, the outcome can be allow, redact, block, rate limit or escalate for human approval. This maps to the suggestion-time step above and to the escalation path for ambiguous cases.

    Each enforcement action also produces audit-ready evidence, so the record of what was checked and what was decided exists without a separate reconstruction exercise. Trussed is deployed self-managed in the customer cloud, with configurable retention and data residency, and has run in production in a regulated enterprise for more than 18 months.

    This does not replace pre-commit, CI and release checks, nor does it replace counsel. It addresses the stage where dependency scanning has no visibility, and it gives legal and audit teams a decision record to review.

    Where licence origin can be checked

    Suggestion

    Origin and licence context assessed before the snippet reaches the editor.

    Commit

    Assistant-originated changes identified and reviewed on the same path as other code.

    CI and release

    Licence statements and notices verified in build and distribution artefacts.

    Evidence

    Each decision recorded in a form legal and audit can retrieve.

    Check your controls against the suggestion stage

    Walk through how policy enforcement and audit-ready evidence apply to coding assistant output in your Apache-2.0 projects.

    Talk to an Expert
    Next step

    How does your AI governance program compare?

    See where your program has gaps in less than 2 minutes.