Skip to content

Commit 12d74d5

Browse files
authored
docs: single security doc (langchain-ai#28515)
1 parent e6a0835 commit 12d74d5

File tree

3 files changed

+32
-36
lines changed

3 files changed

+32
-36
lines changed

SECURITY.md

+31-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,30 @@
11
# Security Policy
22

3+
LangChain has a large ecosystem of integrations with various external resources like local and remote file systems, APIs and databases. These integrations allow developers to create versatile applications that combine the power of LLMs with the ability to access, interact with and manipulate external resources.
4+
5+
## Best practices
6+
7+
When building such applications developers should remember to follow good security practices:
8+
9+
* [**Limit Permissions**](https://en.wikipedia.org/wiki/Principle_of_least_privilege): Scope permissions specifically to the application's need. Granting broad or excessive permissions can introduce significant security vulnerabilities. To avoid such vulnerabilities, consider using read-only credentials, disallowing access to sensitive resources, using sandboxing techniques (such as running inside a container), specifying proxy configurations to control external requests, etc. as appropriate for your application.
10+
* **Anticipate Potential Misuse**: Just as humans can err, so can Large Language Models (LLMs). Always assume that any system access or credentials may be used in any way allowed by the permissions they are assigned. For example, if a pair of database credentials allows deleting data, it’s safest to assume that any LLM able to use those credentials may in fact delete data.
11+
* [**Defense in Depth**](https://en.wikipedia.org/wiki/Defense_in_depth_(computing)): No security technique is perfect. Fine-tuning and good chain design can reduce, but not eliminate, the odds that a Large Language Model (LLM) may make a mistake. It’s best to combine multiple layered security approaches rather than relying on any single layer of defense to ensure security. For example: use both read-only permissions and sandboxing to ensure that LLMs are only able to access data that is explicitly meant for them to use.
12+
13+
Risks of not doing so include, but are not limited to:
14+
* Data corruption or loss.
15+
* Unauthorized access to confidential information.
16+
* Compromised performance or availability of critical resources.
17+
18+
Example scenarios with mitigation strategies:
19+
20+
* A user may ask an agent with access to the file system to delete files that should not be deleted or read the content of files that contain sensitive information. To mitigate, limit the agent to only use a specific directory and only allow it to read or write files that are safe to read or write. Consider further sandboxing the agent by running it in a container.
21+
* A user may ask an agent with write access to an external API to write malicious data to the API, or delete data from that API. To mitigate, give the agent read-only API keys, or limit it to only use endpoints that are already resistant to such misuse.
22+
* A user may ask an agent with access to a database to drop a table or mutate the schema. To mitigate, scope the credentials to only the tables that the agent needs to access and consider issuing READ-ONLY credentials.
23+
24+
If you're building applications that access external resources like file systems, APIs
25+
or databases, consider speaking with your company's security team to determine how to best
26+
design and secure your applications.
27+
328
## Reporting OSS Vulnerabilities
429

530
LangChain is partnered with [huntr by Protect AI](https://huntr.com/) to provide
@@ -14,7 +39,7 @@ Before reporting a vulnerability, please review:
1439

1540
1) In-Scope Targets and Out-of-Scope Targets below.
1641
2) The [langchain-ai/langchain](https://python.langchain.com/docs/contributing/repo_structure) monorepo structure.
17-
3) LangChain [security guidelines](https://python.langchain.com/docs/security) to
42+
3) The [Best practicies](#best-practices) above to
1843
understand what we consider to be a security vulnerability vs. developer
1944
responsibility.
2045

@@ -33,21 +58,21 @@ The following packages and repositories are eligible for bug bounties:
3358
All out of scope targets defined by huntr as well as:
3459

3560
- **langchain-experimental**: This repository is for experimental code and is not
36-
eligible for bug bounties, bug reports to it will be marked as interesting or waste of
61+
eligible for bug bounties (see [package warning](https://pypi.org/project/langchain-experimental/)), bug reports to it will be marked as interesting or waste of
3762
time and published with no bounty attached.
3863
- **tools**: Tools in either langchain or langchain-community are not eligible for bug
3964
bounties. This includes the following directories
40-
- langchain/tools
41-
- langchain-community/tools
42-
- Please review our [security guidelines](https://python.langchain.com/docs/security)
65+
- libs/langchain/langchain/tools
66+
- libs/community/langchain_community/tools
67+
- Please review the [best practices](#best-practices)
4368
for more details, but generally tools interact with the real world. Developers are
4469
expected to understand the security implications of their code and are responsible
4570
for the security of their tools.
4671
- Code documented with security notices. This will be decided done on a case by
4772
case basis, but likely will not be eligible for a bounty as the code is already
4873
documented with guidelines for developers that should be followed for making their
4974
application secure.
50-
- Any LangSmith related repositories or APIs see below.
75+
- Any LangSmith related repositories or APIs (see [Reporting LangSmith Vulnerabilities](#reporting-langsmith-vulnerabilities)).
5176

5277
## Reporting LangSmith Vulnerabilities
5378

docs/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ generate-files:
4747
$(PYTHON) scripts/partner_pkg_table.py $(INTERMEDIATE_DIR)
4848

4949
curl https://raw.githubusercontent.com/langchain-ai/langserve/main/README.md | sed 's/<=/\&lt;=/g' > $(INTERMEDIATE_DIR)/langserve.md
50+
cp ../SECURITY.md $(INTERMEDIATE_DIR)/security.md
5051
$(PYTHON) scripts/resolve_local_links.py $(INTERMEDIATE_DIR)/langserve.md https://github.com/langchain-ai/langserve/tree/main/
5152

5253
copy-infra:

docs/docs/security.md

-30
This file was deleted.

0 commit comments

Comments
 (0)