Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Security documentation update #3183

Merged
merged 41 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
9af48d0
adding security update
udaij12 Jun 7, 2024
c20abda
adding security update
udaij12 Jun 7, 2024
33afd93
doc updates
udaij12 Jun 13, 2024
1670681
Merge branch 'master' into doc_update
udaij12 Jun 13, 2024
91af975
changes to model mode
udaij12 Jun 13, 2024
4565b13
Merge branch 'master' into doc_update
udaij12 Jun 14, 2024
395990c
adding more update
udaij12 Jun 14, 2024
43b25b3
adding token auth paragraph
udaij12 Jun 14, 2024
12ab826
doc changes and logging addition
udaij12 Jun 25, 2024
85590c9
doc changes and logging addition
udaij12 Jun 25, 2024
e2859bb
fix formatting
udaij12 Jun 25, 2024
938f21a
Merge branch 'master' into doc_update
mreso Jun 26, 2024
649f4dd
changing flag name and adding env for model api
udaij12 Jun 26, 2024
e97dff9
Merge branch 'doc_update' of https://github.com/pytorch/serve into do…
udaij12 Jun 26, 2024
e432115
flag fixes
udaij12 Jun 26, 2024
e5940be
fixing doc
udaij12 Jun 26, 2024
8715a0f
changing misaligned name
udaij12 Jun 26, 2024
67c6df6
change to variable name
udaij12 Jun 26, 2024
d966144
change name
udaij12 Jun 26, 2024
bf2f9b9
changing config name
udaij12 Jun 27, 2024
fe8b7fe
Merge branch 'master' into doc_update
udaij12 Jun 27, 2024
573f646
Merge branch 'master' into doc_update
udaij12 Jun 27, 2024
bdcdaae
spellcheck test
udaij12 Jun 27, 2024
c2f29a1
testing docker change
udaij12 Jun 28, 2024
e5af37c
test
udaij12 Jun 28, 2024
1c055ab
Merge branch 'master' into doc_update
udaij12 Jun 28, 2024
57ea245
fixing test_util
udaij12 Jun 28, 2024
7b9ffbd
changes to llm
udaij12 Jun 28, 2024
f49a12b
adding model api flag
udaij12 Jun 28, 2024
5355a9f
fixes to llm update
udaij12 Jul 2, 2024
dbfc91e
Merge branch 'master' into doc_update
udaij12 Jul 2, 2024
2762be2
launcher fix
udaij12 Jul 2, 2024
62078c5
testing token
udaij12 Jul 2, 2024
7dbce37
testing token
udaij12 Jul 2, 2024
b445f8f
fixing docker
udaij12 Jul 2, 2024
e685330
change branch name'
udaij12 Jul 2, 2024
37dfcfc
change branch name'
udaij12 Jul 2, 2024
595e5e8
final changes
udaij12 Jul 2, 2024
5a0a12c
Doc changes
udaij12 Jul 2, 2024
305fb2e
adding key name
udaij12 Jul 2, 2024
9560adc
Merge branch 'doc_update' of https://github.com/pytorch/serve into do…
udaij12 Jul 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# TorchServe

## Security Changes
TorchServe now enforces token authorization and model API control by default. Check the following documentation for more information: [Token Authorization](https://github.com/pytorch/serve/blob/master/docs/token_authorization_api.md), [Model API control](https://github.com/pytorch/serve/blob/master/docs/model_api_control.md)
udaij12 marked this conversation as resolved.
Show resolved Hide resolved

![Nightly build](https://github.com/pytorch/serve/actions/workflows/torchserve-nightly-build.yml/badge.svg)
![Docker Nightly build](https://github.com/pytorch/serve/actions/workflows/docker-nightly-build.yml/badge.svg)
![Benchmark Nightly](https://github.com/pytorch/serve/actions/workflows/benchmark_nightly.yml/badge.svg)
Expand Down
3 changes: 3 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## Security Changes
TorchServe now enforces token authorization and model API control by default. Check the following documentation for more information: [Token Authorization](https://github.com/pytorch/serve/blob/master/docs/token_authorization_api.md), [Model API control](https://github.com/pytorch/serve/blob/master/docs/model_api_control.md)
udaij12 marked this conversation as resolved.
Show resolved Hide resolved

### Deprecation notice:
[Dockerfile.neuron.dev](https://github.com/pytorch/serve/blob/master/docker/Dockerfile.neuron.dev) has been deprecated. Please refer to [deep learning containers](https://github.com/aws/deep-learning-containers/blob/master/available_images.md) repository for neuron torchserve containers.

Expand Down
4 changes: 4 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# TorchServe

## Security Changes
TorchServe now enforces token authorization and model API control by default. Check the following documentation for more information: [Token Authorization](https://github.com/pytorch/serve/blob/master/docs/token_authorization_api.md), [Model API control](https://github.com/pytorch/serve/blob/master/docs/model_api_control.md)


TorchServe is a performant, flexible and easy to use tool for serving PyTorch eager mode and torchscripted models.

## Basic Features
Expand Down
2 changes: 2 additions & 0 deletions docs/inference_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

Inference API is listening on port 8080 and only accessible from localhost by default. To change the default setting, see [TorchServe Configuration](configuration.md).

For all Inference API requests, TorchServe requires the correct Inference token to be included. For more details see [token authorization documentation](./token_authorization_api.md)
udaij12 marked this conversation as resolved.
Show resolved Hide resolved

The TorchServe server supports the following APIs:

* [API Description](#api-description) - Gets a list of available APIs and options
Expand Down
25 changes: 25 additions & 0 deletions docs/management_api.md
mreso marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ TorchServe provides the following APIs that allows you to manage models at runti
4. [Unregister a model](#unregister-a-model)
5. [List registered models](#list-models)
6. [Set default version of a model](#set-default-version)
7. [Refresh tokens for token authorization](#token-authorization-api)

The Management API listens on port 8081 and is only accessible from localhost by default. To change the default setting, see [TorchServe Configuration](./configuration.md).

For all Management API requests, TorchServe requires the correct Management token to be included. For more details see [token authorization documentation](./token_authorization_api.md)

Similar to the [Inference API](inference_api.md), the Management API provides a [API description](#api-description) to describe management APIs with the OpenAPI 3.0 specification.

Alternatively, if you want to use KServe, TorchServe supports both v1 and v2 API. For more details please look into this [kserve documentation](https://github.com/pytorch/serve/tree/master/kubernetes/kserve)
Expand All @@ -19,6 +22,8 @@ Alternatively, if you want to use KServe, TorchServe supports both v1 and v2 API

This API follows the [ManagementAPIsService.RegisterModel](https://github.com/pytorch/serve/blob/master/frontend/server/src/main/resources/proto/management.proto) gRPC API.

To use this API after TorchServe starts, model API control has to be enabled. For more details see [model API control](./model_api_control.md)

`POST /models`

* `url` - Model archive download url. Supports the following locations:
Expand Down Expand Up @@ -441,6 +446,8 @@ print(customizedMetadata)

This API follows the [ManagementAPIsService.UnregisterModel](https://github.com/pytorch/serve/blob/master/frontend/server/src/main/resources/proto/management.proto) gRPC API. It returns the status of a model in the ModelServer.

To use this API after TorchServe starts, model API control has to be enabled. For more details see [model API control](./model_api_control.md)
udaij12 marked this conversation as resolved.
Show resolved Hide resolved

`DELETE /models/{model_name}/{version}`

Use the Unregister Model API to free up system resources by unregistering specific version of a model from TorchServe:
Expand Down Expand Up @@ -522,3 +529,21 @@ curl -v -X PUT http://localhost:8081/models/noop/2.0/set-default
```

The out is OpenAPI 3.0.1 json format. You use it to generate client code, see [swagger codegen](https://swagger.io/swagger-codegen/) for detail.

## Token Authorization API

TorchServe now enforces token authorization by default. Check the following documentation for more information: [Token Authorization](https://github.com/pytorch/serve/blob/master/docs/token_authorization_api.md).
udaij12 marked this conversation as resolved.
Show resolved Hide resolved

This API is used in order to generate a new key to replace either the management or inference key.

Management Example:
```
curl localhost:8081/token?type=management -H "Authorization: Bearer {API Token}"
```
will replace the current management key in the key_file with a new one and will update the expiration time.

Inference example:
```
curl localhost:8081/token?type=inference -H "Authorization: Bearer {API Token}"
```
will replace the current inference key in the key_file with a new one and will update the expiration time.
12 changes: 7 additions & 5 deletions docs/model_control_mode.md → docs/model_api_control.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Model Control Mode
# Model API Control

TorchServe now supports model control mode with two settings "none"(default) and "enabled"
TorchServe now supports model API control with two settings enabled and disabled(default).

udaij12 marked this conversation as resolved.
Show resolved Hide resolved
TorchServe introduces a new feature called model-api-control which allow users to prevent registering and deleting models once the servers are running. This is a security feature which addresses the concern of unwanted registering and deleting of models once the TorchServe servers have started. This is applicable in the scenario where a user may upload malicious code to the model server in the form of a model or where a user may delete a model that is being used. The default behavior prevents users from registering or deleting models once TorchServe is running, and then you can enable the model APIs to allow users to register and delete models whenever using the TorchServe model load APIs.

udaij12 marked this conversation as resolved.
Show resolved Hide resolved
## Two ways to set Model Control
1. Add `--model-api-enabled` to command line when running TorchServe to switch from none to enabled mode. Command line cannot be used to set mode to none, can only be used to set to enabled
udaij12 marked this conversation as resolved.
Show resolved Hide resolved
1. Add `--model-api-enabled` to command line when running TorchServe to switch from disabled to enabled. Command line cannot be used to disabled, can only be used to enabled
2. Add `model_api_enabled=false` or `model_api_enabled=true` to config.properties file
* `model_api_enabled=false` is default and prevents users from registering or deleting models once TorchServe is running
* `model_api_enabled=true` is not default and allows users to register and delete models using the TorchServe model load APIs
Expand All @@ -22,7 +24,7 @@ Priority between cmd and config file follows the following [TorchServer standard

Result: Mode is enabled (no way to disable api mode through cmd)

## Model Control Mode Default
## Model API Control Default
At startup TorchServe loads only those models specified explicitly with the `--models` command-line option. After startup users will be unable to register or delete models in this mode.

### Example default
Expand All @@ -40,7 +42,7 @@ ubuntu@ip-172-31-11-32:~/serve$ curl -X POST "http://localhost:8081/models?url=
```

## Model Control API Enabled
Setting model control to `enabled` allows users to load and unload models using the model load APIs.
Setting model API to `enabled` allows users to load and unload models using the model load APIs.

### Example using cmd line to set mode to enabled
```
Expand Down
1 change: 1 addition & 0 deletions docs/token_authorization_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

TorchServe now enforces token authorization by default

TorchServe introduces a new feature called token-authorization which requires the correct token to be provided when calling an API. This is a security feature which addresses the concern of unwanted API calls. This is applicable in the scenario where an unauthorized user may try to access a running TorchServe server. The default behavior is to enable this feature which creates a key file with the appropriate tokens to be used for API calls. Users can disable this feature to prevent token authorization from being required for API calls.
udaij12 marked this conversation as resolved.
Show resolved Hide resolved
udaij12 marked this conversation as resolved.
Show resolved Hide resolved

## How to set and disable Token Authorization
* Global environment variable: use `TS_DISABLE_TOKEN_AUTHORIZATION` and set to `true` to disable and `false` to enable token authorization. Note that `enable_envvars_config=true` must be set in config.properties for global environment variables to be used
Expand Down
3 changes: 3 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# [Examples showcasing TorchServe Features and Integrations](#torchserve-internals)

## Security Changes
TorchServe now enforces token authorization and model API control by default. This change will impact the current examples so please check the following documentation for more information: [Token Authorization](https://github.com/pytorch/serve/blob/master/docs/token_authorization_api.md), [Model API control](https://github.com/pytorch/serve/blob/master/docs/model_api_control.md)

## TorchServe Internals

* [Creating mar file for an eager mode model](#creating-mar-file-for-eager-mode-model)
Expand Down
3 changes: 3 additions & 0 deletions kubernetes/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Torchserve on Kubernetes

## Security Changes
TorchServe now enforces token authorization and model API control by default. Check the following documentation for more information: [Token Authorization](https://github.com/pytorch/serve/blob/master/docs/token_authorization_api.md), [Model API control](https://github.com/pytorch/serve/blob/master/docs/model_api_control.md)
udaij12 marked this conversation as resolved.
Show resolved Hide resolved

## Overview

This page demonstrates a Torchserve deployment in Kubernetes using Helm Charts. It uses the DockerHub Torchserve Image for the pods and a PersistentVolume for storing config / model files.
Expand Down
Loading