|
| 1 | +# Security Policy |
| 2 | + |
| 3 | +## How we do security |
| 4 | + |
| 5 | +As much as possible, DJL Serving relies on automated tools to do security scanning. In particular, we support: |
| 6 | + |
| 7 | +1. Docker CVE patch scanning: Using AWS ECR |
| 8 | +2. Dependency Analysis: Using Dependabot |
| 9 | +3. Code Analysis: Using CodeQL |
| 10 | + |
| 11 | +## Important Security Guidelines |
| 12 | + |
| 13 | +1. DJL Serving has two APIs: inference and management. More can be available through plugins. |
| 14 | + HTTP - `8080` for both the inference and management API |
| 15 | + |
| 16 | + By default, both APIs are available on port `8080` through HTTP and accessible to `localhost`. The addresses can be configured by following the guide for |
| 17 | + [global configuration](serving/docs/configurations_global.md). |
| 18 | + DJL Serving does not prevent users from configuring the address to be of any value, including the wildcard address `0.0.0.0`. |
| 19 | + Please be aware of the security risks of configuring the address to be `0.0.0.0` as this will give all addresses (including publicly accessible addresses) |
| 20 | + on the host, access to the TorchServe endpoints listening on the ports shown above. |
| 21 | + You should be especially careful with the management API including setting it to a publicly accessible address or forwarding it's port to one. |
| 22 | + If expose, it could allow an attacker to create models and execute arbitrary code on your machine. |
| 23 | +2. By [default](serving/docker/Dockerfile), the docker images are configured to expose the port `8080` to the host. |
| 24 | + The default DJL Serving configuration in the container, which is executed by the docker entrypoint, will expose both the inference and management APIs set to `http://0.0.0.0:8080`. |
| 25 | + This is designed for internal isolated services or development work. For other use cases, provide alternative configurations to avoid exposing the management API. |
| 26 | + |
| 27 | +3. Be sure to validate the authenticity of all model files and model artifacts being used with DJL Serving. |
| 28 | + 1. A model file being downloaded from the internet from an untrustworthy source may have malicious code. This can compromise the integrity of your application, slow your device, or extract data. |
| 29 | + Data that is on the device may include configurations, model files, inference requests, logs, and other standard important data such as security keys. |
| 30 | + 2. DJL Serving executes the arbitrary python code packaged in the model file. Make sure that you've either audited that the code you're using is safe and/or is from a source that you trust. |
| 31 | + 3. DJL Serving supports custom [plugins](plugins). These should also only be used from trusted sources. |
| 32 | + 4. Running TorchServe inside a container environment and loading an untrusted model file does not guarantee isolation from a security perspective. |
| 33 | +4. Enable SSL: |
| 34 | + |
| 35 | + DJL Serving supports two ways to configure SSL: |
| 36 | + 1. Using a keystore |
| 37 | + 2. Using private-key/certificate files |
| 38 | + |
| 39 | + You can find more details in the [configuration guide](serving/docs/configurations_global.md#enable-ssl). |
| 40 | +5. Prepare your model against bad inputs and prompt injections. Some recommendations: |
| 41 | + 1. Pre-analysis: check how the model performs by default when exposed to prompt injection (e.g. using [fuzzing for prompt injection](https://github.com/FonduAI/awesome-prompt-injection?tab=readme-ov-file#tools)). |
| 42 | + 2. Input Sanitation: Before feeding data to the model, sanitize inputs rigorously. This involves techniques such as: |
| 43 | + - Validation: Enforce strict rules on allowed characters and data types. |
| 44 | + - Filtering: Remove potentially malicious scripts or code fragments. |
| 45 | + - Encoding: Convert special characters into safe representations. |
| 46 | + - Verification: Run tooling that identifies potential script injections (e.g. [models that detect prompt injection attempts](https://python.langchain.com/docs/guides/safety/hugging_face_prompt_injection)). |
| 47 | +6. If you intend to run multiple models in parallel with shared memory, it is your responsibility to ensure the models do not interact or access each other's data. The primary areas of concern are tenant isolation, resource allocation, model sharing and hardware attacks. |
| 48 | + |
| 49 | +## Reporting a Vulnerability |
| 50 | + |
| 51 | +If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public github issue. |
0 commit comments