Skip to content
Open
Changes from all commits
Commits
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
8 changes: 5 additions & 3 deletions apps/agentstack-sdk-py/src/agentstack_sdk/server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@
from agentstack_sdk.platform.provider import Provider
from agentstack_sdk.server.agent import Agent, AgentFactory
from agentstack_sdk.server.agent import agent as agent_decorator
from agentstack_sdk.server.middleware.platform_auth_backend import PlatformAuthBackend
from agentstack_sdk.server.store.context_store import ContextStore
from agentstack_sdk.server.store.memory_context_store import InMemoryContextStore
from agentstack_sdk.server.store.platform_context_store import PlatformContextStore
from agentstack_sdk.server.telemetry import configure_telemetry as configure_telemetry_func
from agentstack_sdk.server.utils import cancel_task
from agentstack_sdk.types import SdkAuthenticationBackend
Expand Down Expand Up @@ -72,7 +73,7 @@ async def serve(
self,
*,
configure_logger: bool = True,
configure_telemetry: bool = False,
configure_telemetry: bool = True,
self_registration: bool = True,
self_registration_id: str | None = None,
task_store: TaskStore | None = None,
Expand Down Expand Up @@ -140,7 +141,8 @@ async def serve(
if not self._agent_factory:
raise ValueError("Agent is not registered")

context_store = context_store or InMemoryContextStore()
context_store = context_store or PlatformContextStore()
auth_backend = auth_backend or PlatformAuthBackend()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-high high

The pull request changes the default auth_backend to PlatformAuthBackend(), which introduces a significant security risk. The PlatformAuthBackend implementation (in apps/agentstack-sdk-py/src/agentstack_sdk/server/middleware/platform_auth_backend.py) defaults to using the request's Host header for JWT audience validation when PLATFORM_AUTH__PUBLIC_URL is not configured (line 107). This makes the agent vulnerable to Host Header Injection, where an attacker can use a valid JWT issued for a different agent on the same platform to authenticate by manipulating the Host header. Additionally, the backend lacks issuer (iss) validation and leaks internal error details (such as platform URLs and discovery failures) in authentication responses. Making this the default 'happy path' without enforcing secure configuration significantly weakens the SDK's default security posture.

self._agent = self._agent_factory(context_store.modify_dependencies)
card_url = url and url.strip()
self._agent.card.url = card_url.rstrip("/") if card_url else f"http://{host}:{port}"
Expand Down
Loading