Understanding Viral Licenses
"Viral" licenses, more formally known as copyleft licenses, require derivative works to be distributed under the same license terms. This guide explains how these licenses work, their implications, and how to work with them effectively. For businesses seeking alternatives, see our commercial-friendly licenses guide.What Makes a License "Viral"?
A viral license "infects" derivative works with its terms. If you modify or extend viral-licensed code, your changes must typically be released under the same license.
Key Characteristics
- Reciprocal sharing: Modifications must be shared
- License persistence: Same license applies to derivatives
- Source disclosure: Source code must be made available
- No additional restrictions: Cannot add extra limitations
Major Viral Licenses
GPL (GNU General Public License)
GPLv2
- Released: 1991
- Used by: Linux kernel, Git, WordPress
- Key requirement: Source code for distributed binaries
- Trigger: Distribution of binary
# GPLv2 obligations triggered by:
- Distributing compiled binaries
- Selling products containing GPL code
- SaaS deployment (generally NOT triggered)GPLv3
- Released: 2007
- Additional provisions: Patent protection, anti-tivoization
- Used by: GCC, GIMP, Bash
- Key difference: Prevents hardware restrictions
AGPL (Affero General Public License)
The "network copyleft" license:
- Trigger: Network use (including SaaS)
- Requirement: Provide source to network users
- Used by: MongoDB (formerly), Nextcloud, Mastodon
// AGPL Example - Must share source even for SaaS
if (userAccessesOverNetwork) {
mustProvideSourceCode = true;
}LGPL (Lesser General Public License)
The "library copyleft" license:
- Allows: Proprietary software to link to LGPL libraries
- Requires: Share modifications to library itself
- Used by: GTK, Qt (dual-licensed), glibc
Other Copyleft Licenses
| License | Strength | Scope | Used By |
|---|---|---|---|
| MPL 2.0 | Weak | File-level | Firefox, Thunderbird |
| EPL 2.0 | Weak | Module-level | Eclipse IDE |
| CDDL | Weak | File-level | OpenSolaris, NetBeans |
| OSL 3.0 | Strong | Network use | Few projects |
How Viral Licenses Spread
Direct Inclusion
# Your proprietary file
import gpl_library # Now your code may need to be GPL
def my_function():
gpl_library.function() # Using GPL codeStatic Linking
// Compiling GPL code into your binary
#include "gpl_header.h" // Creates derivative work
int main() {
gpl_function(); // Your binary must be GPL
}Modification
// Modifying GPL code
class MyClass extends GPLClass { // Derivative work
// Your additions must be GPL
}The Derivative Work Boundary
What Constitutes a Derivative Work?
Clearly Derivative:- Copy-pasting GPL code
- Modifying GPL source files
- Static linking to GPL libraries
- Subclassing GPL classes
- Dynamic linking (debated)
- Separate process communication
- Network API calls
- Data format compatibility
Gray Areas
# Uncertain scenarios
# 1. Plugin systems
def my_plugin(): # Is this derivative?
return gpl_host.api_call()
# 2. Macro/Template expansion
GPL_MACRO(my_code) # Expanded at compile time
# 3. Interpreted languages
eval(gpl_code + my_code) # Combined at runtimeWorking with Viral Licenses
Isolation Strategies
1. Process Separation
# Safe: Separate processes
./proprietary_app | ./gpl_tool2. Network Services
# Safe: Network API
import requests
response = requests.get("http://gpl-service/api")3. Clean Room Implementation
- Read specifications, not code
- Independent implementation
- No copy-paste
- Document development process
Compliance Strategies
For Businesses
- Audit Dependencies
# Scan for viral licenses
license-scanner --fail-on GPL,AGPL,LGPL- Establish Boundaries
[Proprietary Core] <--> [API Layer] <--> [GPL Components]- Alternative Components
- Replace readline (GPL) with libedit (BSD)
- Use PostgreSQL (PostgreSQL) instead of MySQL (GPL)
- Choose OpenSSL (Apache 2.0) over GNU TLS (LGPL)
For Open Source Projects
- Choose Compatible License
- GPL projects can use: GPL, LGPL, MIT, BSD, Apache
- AGPL projects need AGPL-compatible code
- Consider dual licensing for flexibility
- Document License Rationale
## Why We Chose GPL
1. Ensure improvements benefit community
2. Prevent proprietary forks
3. Level playing field for competitorsCommon Misconceptions
Myth 1: "GPL Prohibits Commercial Use"
Reality: GPL allows selling, just requires source disclosureMyth 2: "Using GPL Software Internally Requires Disclosure"
Reality: Internal use without distribution has no obligationsMyth 3: "GPL is Anti-Business"
Reality: Many successful businesses use GPL (Red Hat, SUSE, etc.)Myth 4: "Dynamic Linking Avoids GPL"
Reality: FSF claims it doesn't; legally untestedMyth 5: "AGPL Affects All Network Software"
Reality: Only if AGPL code is modified and network-accessibleReal-World Implications
For Startups
Consideration: Fast development vs. license obligations
Strategy: Use GPL for non-core components
Risk: Acquisition complications
Mitigation: Clear license boundariesFor Enterprises
Consideration: Compliance across thousands of projects
Strategy: Automated scanning and approval workflows
Risk: Supply chain contamination
Mitigation: Vendor license requirementsFor Developers
Consideration: Career and project impact
Strategy: Understand before contributing
Risk: Employer IP conflicts
Mitigation: Contribution agreementslicense compatibility Matrix
| Your License | Can Include | Cannot Include |
|---|---|---|
| GPL-2.0 | MIT, BSD, Apache-2.0 | GPL-3.0, AGPL |
| GPL-3.0 | MIT, BSD, Apache-2.0, GPL-2.0+ | AGPL |
| AGPL-3.0 | GPL-3.0, MIT, BSD | Proprietary |
| LGPL-2.1 | Any (with conditions) | - |
| MIT | MIT, BSD, ISC | GPL (creates GPL project) |
Detection and Compliance Tools
Scanning Tools
# FOSSology - Comprehensive license scanning
fossology --repo /path/to/code
# Scancode - Detailed license detection
scancode --license --copyright /path/to/code
# REUSE - FSFE compliance tool
reuse lintCI/CD Integration
# GitHub Actions example
- name: License Check
uses: fossa/fossa-action@v2
with:
api-key: ${{ secrets.FOSSA_API_KEY }}
fail-on: GPL-3.0,AGPL-3.0Best Practices
1. Clear Documentation
## License
This project is licensed under GPL-3.0.
Commercial licensing available - contact sales@company.com
### Third-party licenses
- Component A: MIT
- Component B: Apache-2.0
- Component C: GPL-3.0 (isolated in subprocess)2. License Headers
# [SPDX](/tools/spdx-tools)-License-Identifier: GPL-3.0-or-later
# Copyright (C) 2024 Your Name3. Contribution Guidelines
## Contributing
By contributing, you agree that your contributions will be licensed under GPL-3.0.Future of Copyleft
Trends
- Declining new projects: Fewer choosing strong copyleft
- Permissive shift: Move toward MIT/Apache
- New models: Source-available, fair-code licenses
- Network copyleft: Growing importance with cloud
Evolving Landscape
- Courts beginning to rule on GPL interpretation
- New licenses addressing modern development
- Container/microservice architecture impacts
- AI/ML training data questions
Related Articles
- Latest SBOM Standards
- CycloneDX vs SPDX
- Supply Chain Security
- SBOM Automation Guide
- Complete SBOM Tooling Overview
Conclusion
Viral licenses serve important purposes in open source: ensuring freedom, preventing proprietary lock-in, and building collaborative communities. While they require careful consideration in commercial contexts, they're neither inherently good nor bad—they're tools with specific characteristics that may or may not align with your goals.
Understanding these licenses helps you:
- Make informed decisions
- Avoid legal issues
- Contribute effectively
- Build sustainable projects
Whether you choose to use, avoid, or embrace viral licenses, the key is understanding their implications and planning accordingly.