lablup / lablup/backend.ai

Add secure cookie attributes (httponly, secure, samesite) in appproxy

Open
#7,026 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
670
Forks
183
Avg merge
17h 7m
Merged PRs (30d)
358

Description

## Problem

Cookies are being set without security attributes, making them vulnerable to:

- **XSS attacks** (missing `httponly`)
- **Man-in-the-middle attacks** (missing `secure`)
- **CSRF attacks** (missing `samesite`)

## Affected Files

- `src/ai/backend/appproxy/worker/api/setup.py:171`

## Scanner Reference

- **Sparrow**: INSECURE_PERSISTENT_COOKIE - Issues #1686, #1687, #1688
- **CWE**: CWE-614 (Sensitive Cookie Without 'Secure' Flag)

## Recommended Fix

Add security attributes when setting cookies:

```python
response.set_cookie(
name,
value,
httponly=True,
secure=True,
samesite='Lax' # or 'Strict' depending on requirements
)
```

JIRA Issue: BA-3201

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.