Skip to content

Commit 4492f12

Browse files
committed
Refine sessions security guidance
1 parent a265d0e commit 4492f12

2 files changed

Lines changed: 22 additions & 31 deletions

File tree

articles/container-apps/sessions-usage.md

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Authorization: Bearer <TOKEN>
5454

5555
This request is forwarded to the container in the session with the identifier for the user's ID.
5656

57-
If the session isn't already running, Azure Container Apps automatically allocates a session from the pool before forwarding the request.
57+
If no session exists for the given identifier, Azure Container Apps automatically allocates one from the pool before forwarding the request.
5858

5959
In this example, the session's container receives the request at `http://0.0.0.0:<INGRESS_PORT>/<API_PATH_EXPOSED_BY_CONTAINER>`.
6060

@@ -78,31 +78,26 @@ The identifier must be a string that is 4 to 128 characters long and can contain
7878

7979
## Security
8080

81+
### Security model
82+
8183
Dynamic sessions are built to run untrusted code and applications in a secure and isolated environment. While sessions are isolated from one another, anything within a single session, including files and environment variables, is accessible by users of the session.
8284

8385
Only configure or upload sensitive data to a session if you trust the users of the session.
8486

87+
### Network access
88+
8589
By default, sessions are prevented from making outbound network requests. You can control network access by configuring network status settings on the session pool.
8690

87-
- **Use strong, unique session identifiers**: Always generate session identifiers that are long and complex to prevent brute-force attacks. Use cryptographic algorithms to create identifiers that are hard to guess.
91+
### Best practices
8892

93+
- **Secure identifiers**: Use secure [session identifiers](sessions-usage.md#identifiers) at all times. Generate session identifiers using cryptographic methods to ensure unique and unpredictable values. Avoid using sequential IDs that could be guessed by an attacker.
94+
- **Use HTTPS**: Always use HTTPS to encrypt data in transit. This protects session identifiers and any sensitive data exchanged between the client and server from being intercepted.
95+
- **Limit session lifetime**: Implement timeouts for sessions. For instance, allow a maximum of 15 minutes of inactivity before the session is automatically terminated. This helps mitigate risks due to a lost or unattended device.
8996
- **Limit session visibility**: Set strict access controls to ensure that session identifiers are only visible to the session pool. Avoid exposing session IDs in URLs or logs.
90-
91-
- **Implement short expiration times**: Configure session identifiers to expire after a short period of inactivity. This approach minimizes the risk of sessions being hijacked after a user has finished interacting with your application.
92-
9397
- **Regularly rotate session credentials**: Periodically review and update the credentials associated with your sessions. Rotation decreases the risk of unauthorized access.
94-
95-
- **Utilize secure transmission protocols**: Always use HTTPS to encrypt data in transit, including session identifiers. This approach protects against man-in-the-middle attacks.
96-
9798
- **Monitor session activity**: Implement logging and monitoring to track session activities. Use these logs to identify unusual patterns or potential security breaches.
98-
9999
- **Validate user input**: Treat all user input as dangerous. Use input validation and sanitation techniques to protect against injection attacks and ensure that only trusted data is processed.
100100

101-
To fully secure your sessions, you can:
102-
103-
- [Use Microsoft Entra ID authentication and authorization](#authentication)
104-
- [Protect session identifiers](#protect-session-identifiers)
105-
106101
### <a name="authentication"></a>Authentication and authorization
107102

108103
When you send requests to a session using the pool management API, authentication is handled using Microsoft Entra tokens. Only Microsoft Entra tokens from an identity belonging to the *Azure ContainerApps Session Executor* role on the session pool are authorized to call the pool management API.

articles/container-apps/sessions.md

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ With sessions, you get:
2626
- **Instant Startup**: Prewarmed pools enable subsecond launch times for interactive workloads. New sessions are allocated in milliseconds thanks to pools of ready but unallocated sessions.
2727
- **Scalable by Design**: Handle hundreds or thousands of concurrent sessions without manual intervention.
2828
- **Managed lifecycle**: Sessions are automatically deprovisioned after use or after a configurable cooldown period, ensuring efficient resource usage.
29-
- **Simple Access**: Sessions are accessed through a REST API with a unique identifier. If a session doesn’t exist, a new one is automatically allocated.
30-
- **API Access**: Sessions are exposed to your application via a single HTTP endpoint.
3129

3230

3331
## Common Scenarios
@@ -46,30 +44,26 @@ Dynamic sessions are useful in a variety of situations, including:
4644
- **Session**
4745
A session is the actual execution environment where your code or container runs. Sessions are ephemeral and isolated, designed for short-lived tasks. When you create a session, it's allocated from the session pool, ensuring fast startup. After the task completes or the cooldown period expires, the session is destroyed and resources are cleaned up.
4846

49-
- **Session Lifecycle**
50-
Sessions follow a clear flow from creation to cleanup:
47+
- **Session Lifecycle**
48+
When your application sends a request with a session identifier, the session pool allocates a session automatically. The session stays active as long as requests continue. Once the cooldown period expires with no activity, the session is destroyed and its resources are cleaned up automatically.
5149

52-
1. **Request Received**: Your application calls the REST API to create or retrieve a session using a unique identifier.
53-
2. **Pending**: The system validates the request and checks for available resources.
54-
3. **Unallocated**: A session exists but isn't yet assigned to a workload. If a prewarmed session is available in the pool, it moves quickly to allocation.
55-
4. **Allocated**: The session becomes active and runs your code or container. This is the execution phase.
56-
5. **Destroyed**: After the task completes or the cooldown period expires, the session is terminated and resources are cleaned up automatically.
50+
- **Request routing and identifiers**
51+
Sessions are accessed through the session pool management endpoint. Requests include an `identifier` query parameter, and the pool routes the request to an existing session or allocates a new one if needed. The request path after the management endpoint is forwarded to the session container.
5752

58-
This lifecycle ensures fast startup, efficient resource use, and automatic cleanup without manual intervention.
53+
- **Session Pool Types**
54+
- **Code Interpreter Session Pools**: These use platform built-in containers that provide preconfigured environments for running code, including AI-generated scripts. Ideal for scenarios like LLM-driven workflows or secure code execution.
55+
- **Custom Container Session Pools**: Bring-your-own-container for custom workloads that require specific dependencies or runtime environments.
5956

60-
- **Session Types**
61-
- **Code Interpreter Sessions**: These are platform built-in containers that provide preconfigured environments for running code, including AI-generated scripts. Ideal for scenarios like LLM-driven workflows or secure code execution.
62-
- **Custom Container Sessions**: Bring-your-own-container for custom workloads that require specific dependencies or runtime environments.
6357

58+
#### Session Pool Types Comparison
6459

65-
#### Session Types Comparison
66-
67-
| | **Code Interpreter Session** | **Custom Container Session** |
60+
| | **Code Interpreter Session Pool** | **Custom Container Session Pool** |
6861
|---------------|------------------------------|------------------------------|
6962
| **Best For** | Running AI‑generated code, user-submitted scripts, or quick secure code execution without managing a runtime environment. | Workloads requiring a custom runtime, libraries, binaries, or specialized tools not supported by built-in interpreters. |
7063
| **Environment** | Preconfigured with common runtimes and tools; no container build or image publishing required. | Fully customizable container image with your own dependencies, packages, and configuration. |
7164
| **When to Choose** | Choose this for simplicity, fastest startup, and minimal setup. | Choose this when you need full control over the execution environment or rely on custom dependencies. |
7265
| **Ideal Use Cases** | LLM workflows, code interpretation, educational/sandbox scenarios, safe execution of user code. | Custom compute tasks, proprietary interpreters, specialized environments, or workloads with specific OS/library requirements. |
66+
| **Language and protocol** | Limited to the built-in runtimes and the REST API surface provided by the code interpreter. | Any language or stack supported by your container, with any TCP protocol you choose to expose. |
7367
| **Image Requirement** | None—uses platform built‑in interpreter environments. | Required—supply your own container image URI. |
7468

7569
For more information, see [Usage](./sessions-usage.md).
@@ -94,6 +88,8 @@ Dynamic sessions are available in the following regions. Both code interpreter a
9488
| West US 3 | UK West | | |
9589
| | West Europe | | |
9690

91+
> [!NOTE]
92+
> Regional availability may change. To verify current availability, check the **Location** dropdown when creating a session pool in the Azure portal.
9793
9894
## Security
9995
Dynamic sessions are designed to run untrusted code in isolated environments. For information about securing your sessions, see [Security](./sessions-usage.md#security).
@@ -105,5 +101,5 @@ Custom container sessions are billed based on the resources consumed by the sess
105101

106102
## Next Steps
107103
- Learn how to configure [Session pools](./session-pool.md)
108-
- Learn how to use [Dynamic sessions](./sessions-usage.md)
104+
- Learn how to use [Dynamic sessions](./sessions-usage.md), including security and best practices
109105

0 commit comments

Comments
 (0)