Skip to content

Commit c8d70e3

Browse files
authored
feat(models): review and enforce provider safety notices (#7672)
* feat(gateway): reserve shared budgets for free model requests Signed-off-by: Jalil <reachjalil@gmail.com> * chore(gateway): follow the source style checks Signed-off-by: Jalil <reachjalil@gmail.com> * feat(gateway): pause free usage by safety identifier Signed-off-by: Jalil <reachjalil@gmail.com> * test(gateway): verify cross-organization pauses and streamed refusals Signed-off-by: Jalil <reachjalil@gmail.com> * feat(desktop): bind subsidized model requests to desktop sessions Signed-off-by: Jalil <reachjalil@gmail.com> * fix(den): audit safety pauses and report effective enforcement Signed-off-by: Jalil <reachjalil@gmail.com> * fix(gateway): read free budget status in the accounting transaction Signed-off-by: Jalil <reachjalil@gmail.com> * fix(gateway): skip safety storage until enforcement is enabled Signed-off-by: Jalil <reachjalil@gmail.com> * feat(models): share free usage across founders and desktops Signed-off-by: Jalil <reachjalil@gmail.com> * feat(gateway): pause free usage by safety identifier Signed-off-by: Jalil <reachjalil@gmail.com> * test(gateway): verify cross-organization pauses and streamed refusals Signed-off-by: Jalil <reachjalil@gmail.com> * fix(den): audit safety pauses and report effective enforcement Signed-off-by: Jalil <reachjalil@gmail.com> * fix(gateway): skip safety storage until enforcement is enabled Signed-off-by: Jalil <reachjalil@gmail.com> * feat(desktop): bind subsidized model requests to desktop sessions Signed-off-by: Jalil <reachjalil@gmail.com> * feat(models): review and enforce provider safety notices Signed-off-by: Jalil <reachjalil@gmail.com> * ci(den): run safety case tests when gateway inputs change Signed-off-by: Jalil <reachjalil@gmail.com> * test(den): discover free model security tests together Signed-off-by: Jalil <reachjalil@gmail.com> --------- Signed-off-by: Jalil <reachjalil@gmail.com>
1 parent b79b984 commit c8d70e3

20 files changed

Lines changed: 26372 additions & 7 deletions

File tree

‎.github/scripts/build-inputs.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ export function buildInputPatterns(target, options = {}) {
166166
// The MySQL-backed Den API tests (ee/apps/den-api/test/api) and the files
167167
// they read outside the den-api workspace closure.
168168
case "den-api-tests": patterns = [
169-
...api(), ...closure("@openwork-ee/headless-runner"), "evals/packages/labs/**", "evals/packages/open-workplace/**",
169+
...api(), ...closure("@openwork-ee/headless-runner"), ...closure("@openwork-ee/gateway"), "evals/packages/labs/**", "evals/packages/open-workplace/**",
170170
"packaging/helm/openwork-ee/values.schema.json",
171171
"packaging/docker/docker-compose.web-local.yml", "packaging/docker/docker-compose.ci-mysql.yml",
172172
CI_WORKFLOW, ".github/scripts/classify-ci-changes.mjs", ".github/actions/setup-tests/**",

‎docs/enterprise/outbound-access.json‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@
3030
{
3131
"host": "api.openai.com",
3232
"kind": "fetched",
33-
"components": ["renderer", "server"],
34-
"purpose": "Direct OpenAI Realtime voice, image generation, and native model requests when an OpenAI provider is configured.",
33+
"components": ["renderer", "server", "den"],
34+
"purpose": "Direct OpenAI Realtime voice, image generation, and native model requests when an OpenAI provider is configured. Den retrieves safety case metadata when safety notice handling is configured.",
3535
"requirement": "opt-in",
36-
"blockedEffect": "Direct OpenAI voice, image, or native model requests fail for users who configured OpenAI.",
36+
"blockedEffect": "Direct OpenAI voice, image, or native model requests fail for users who configured OpenAI. Den cannot verify or import safety cases.",
3737
"override": null
3838
},
3939
{
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Review OpenAI safety notices
2+
3+
This workflow covers Free Auto requests paid for by OpenWork through Chat Completions and Responses. Platform admins can review provider cases, identify a matching signed-in user, inspect recent request IDs, and stop future free model requests. Warnings open for review. A verified deactivation creates a durable block for the supplied Free Auto identifier. A block applies in every organization where that identity uses Free Auto.
4+
5+
## Set up the receiving endpoint
6+
7+
1. Apply the safety-case database migration and upgrade Den and every gateway replica.
8+
2. In the OpenAI organization that owns the inference credential, register the Den endpoint `/v1/webhooks/openai/safety` for `safety.warning_issued` and `safety.deactivation_issued`. Set `OPENAI_SAFETY_WEBHOOK_SECRET` in Den and configure `OPENAI_SAFETY_READ_KEY` with only the organization's Safety Read permission. Use the documented organization-level setup. [OpenAI safety enforcement notifications](https://developers.openai.com/api/docs/guides/safety-enforcement)
9+
3. Verify delivery and import a known case. The receiver verifies the signature and timestamp over the raw event, looks up the case on the fixed OpenAI API host, and acknowledges supported notices after committing them. Monitor non-success webhook deliveries. A failed lookup returns 503 so OpenAI retries. After the delivery window, import missed cases by ID. Repeated delivery preserves prior decisions. [OpenAI webhooks](https://developers.openai.com/api/docs/guides/webhooks)
10+
4. Enable `freeAutoSafetyCases` for everyone on this deployment. Check `enforcementEnabled` through the admin API. With this rollout active, the gateway records the signed-in user mapping before dispatch and checks for any open block on the primary database. An in-flight request can finish. Older usage can be matched if its original membership still identifies the same user.
11+
12+
## Work a case
13+
14+
The following paths require a platform administrator's authenticated Den session. Keep the case ID, assignee, due time, incident timestamp, evidence references and disposition in an access-controlled incident record. Keep prompt contents, credentials, and personal details out of tickets by default.
15+
16+
| Situation | Operator action |
17+
| --- | --- |
18+
| An email or webhook names a case | For an email, send `POST /v1/admin/free-auto/safety-cases/import` with `{"caseId":"C-example"}`. Den verifies the case with OpenAI. Review waiting cases with `GET /v1/admin/free-auto/safety-cases?state=review` and provider or local blocks with `state=blocked`. Pass `nextCursor` as `cursor` for the next page. |
19+
| A warning names an identifier | Open `GET /v1/admin/free-auto/safety-cases/C-example`. Check the member match, request IDs and times against the notice and authorized request logs. The provider's case creation time can differ from the activity time. Guest evidence can represent a shared machine or network. A count of other accounts on shared desktops is a lead for review. |
20+
| An organization-level warning gives no identifier | Confirm the notice and affected OpenAI organization, project, credentials, endpoints and time window. Find specific request evidence, including failed upstream requests where available. For a matching ledger request send `POST /v1/admin/free-auto/safety-cases/from-request` with `{"requestId":"<OpenWork request ID>"}`. Follow the returned local case. If attribution is inconclusive, escalate for provider details and contain the affected credential or route under the incident procedure. |
21+
| Review is in progress | Assign an owner. If containment is warranted, use the existing time-limited safety pause and set a review deadline before expiry. Check its separate rollout. An isolated request refusal or an ordinary spend alert alone does not establish misconduct. |
22+
| Review confirms misuse | Send `POST /v1/admin/free-auto/safety-cases/{caseId}/decision` with `{"decision":"confirmed_misuse"}`. Verify effective enforcement. Review later attempts and any other OpenWork-funded routes using the same provider account. An explicit provider account-suspension request also requires prompt action at the account scope specified in the notice. |
23+
| Investigation clears a warning, or a local appeal succeeds | Record `no_violation` on an open warning or local review, or `appeal_upheld` on its local block. The case keeps each reviewer, decision and time. Other cases and temporary pauses keep their own state. Use the provider appeal path for a disputed deactivation. Ordinary local review cannot lift provider deactivations. |
24+
25+
A different OpenWork account has a different safety identifier. Review corroborated evidence before restricting additional identities. Never issue a replacement identifier or switch a restricted request to a different credential or model to get around a provider block. Use account or credential containment separately when needed, including for suspected compromise. This feature leaves organization creation and other provider routes under their existing controls.
26+
27+
## Policy references
28+
29+
The published Services Agreement assigns responsibility for end-user use to the customer and describes suspension requests in section 8.1. Check the agreement governing the deployment and the actual notice when deciding scope. [OpenAI Services Agreement](https://openai.com/policies/services-agreement/) · [Usage Policies](https://openai.com/policies/usage-policies/)
30+
31+
OpenAI recommends a stable, pseudonymous end-user identifier and controls against repeat access after a block. OpenWork assigns the identifier server-side. Keep an internal support path for disputed findings and use the appeal instructions in provider notices. [Safety best practices](https://developers.openai.com/api/docs/guides/safety-best-practices) · [Safety checks](https://developers.openai.com/api/docs/guides/safety-checks)

‎ee/apps/den-api/package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"seed:demo-org": "pnpm run build:den-db && OPENWORK_DEV_MODE=${OPENWORK_DEV_MODE:-1} DATABASE_URL=${DATABASE_URL:-mysql://root:password@127.0.0.1:3306/openwork_den} DEN_DB_ENCRYPTION_KEY=${DEN_DB_ENCRYPTION_KEY:-local-dev-db-encryption-key-please-change-1234567890} BETTER_AUTH_SECRET=${BETTER_AUTH_SECRET:-local-dev-secret-not-for-production-use!!} BETTER_AUTH_URL=${BETTER_AUTH_URL:-http://localhost:${DEN_WEB_PORT:-3005}} tsx --conditions=development scripts/seed-demo-org.ts",
2424
"start": "sh scripts/start.sh",
2525
"typecheck": "pnpm --filter @openwork/mcp-apps build && tsc -p tsconfig.json --noEmit",
26+
"pretest:api:security": "node --conditions=development --import tsx --test test/api/free-*.api.test.ts",
2627
"test:api": "node --conditions=development --import tsx --test test/api/*.api.test.ts",
2728
"test:api:security": "node --conditions=development --import tsx --test test/api/admin-security.api.test.ts test/api/audit-secrets.api.test.ts test/api/auth-rate-limits.api.test.ts test/api/computer-disconnect.api.test.ts test/api/config-blobs-import-first-pass.api.test.ts test/api/external-connection-list-changed.api.test.ts test/api/external-mcp-scope-refusal.api.test.ts test/api/feature-outcomes.api.test.ts test/api/ga-shared-roles.api.test.ts test/api/gateway-keys.api.test.ts test/api/gateway-api-keys.api.test.ts test/api/gateway-limits-invited-members.api.test.ts test/api/gateway-limits-invited-members-edges.api.test.ts test/api/managed-installer-releases.api.test.ts test/api/mcp-connection-route-access.api.test.ts test/api/mcp-oauth.api.test.ts test/api/mcp-policy.api.test.ts test/api/mcp-thread-events.api.test.ts test/api/native-mcp-events.api.test.ts test/api/native-oauth-refresh.api.test.ts test/api/me-invitations.api.test.ts test/api/member-api-keys.api.test.ts test/api/member-features.api.test.ts test/api/remote-devices.api.test.ts test/api/remote-access-off.api.test.ts test/api/remote-session-access.api.test.ts test/api/sandbox-only-permissions.api.test.ts test/api/org-default-model.api.test.ts test/api/oauth-token-rate-limit.api.test.ts test/api/pattern-time-limit.api.test.ts test/api/scim-email-change.api.test.ts test/api/session-token-hashing.api.test.ts test/api/skill-access.api.test.ts test/api/skill-files.api.test.ts test/api/tenant-isolation.api.test.ts test/api/workbot-settings-permissions.api.test.ts test/api/litellm-entra-sign-in.api.test.ts"
2829
},

‎ee/apps/den-api/src/audit/routes/platform.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,12 @@ export const platformAuditRoutes: readonly AuditRouteDeclaration[] = [
154154
platform("GET", "/v1/admin/opportunities/outreach", "platform.opportunities.outreach.read", "platform.admin", "platform_report", null, `${ADMIN} Internal sales list: names the person to write to at each listed organization from existing member records. Platform evidence only; sends no message.`),
155155
platform("POST", "/v1/admin/opportunities/accounts/:organizationId/actions", "platform.opportunities.account.follow_up.record", "platform.admin", "organization", "organizationId", `${ADMIN} Records an internal follow-up step in account_follow_up tables. Platform evidence only: sales notes are not tenant activity and never reach the organization's audit log. Sends no message.`),
156156
platform("GET", "/v1/admin/metrics", "platform.metrics.read", "platform.admin", "platform_report", null, ADMIN),
157+
platform("POST", "/v1/webhooks/openai/safety", "platform.free_auto_safety_case.receive", "platform.webhook", "free_auto_safety_case", null, "Verified organization-level provider notice, with authoritative case details retrieved before recording. No tenant attribution."),
158+
platform("POST", "/v1/admin/free-auto/safety-cases/from-request", "platform.free_auto_safety_case.open", "platform.admin", "free_auto_safety_case", null, ADMIN),
159+
readOnly("/v1/admin/free-auto/safety-cases", "platform.free_auto_safety_case.list", "platform.admin", "free_auto_safety_case", null, ADMIN),
160+
readOnly("/v1/admin/free-auto/safety-cases/:caseId", "platform.free_auto_safety_case.inspect", "platform.admin", "free_auto_safety_case", "caseId", ADMIN),
161+
platform("POST", "/v1/admin/free-auto/safety-cases/import", "platform.free_auto_safety_case.import", "platform.admin", "free_auto_safety_case", null, ADMIN),
162+
platform("POST", "/v1/admin/free-auto/safety-cases/:caseId/decision", "platform.free_auto_safety_case.decide", "platform.admin", "free_auto_safety_case", "caseId", ADMIN),
157163
platform("PUT", "/v1/admin/free-auto/safety-pause", "platform.free_auto_safety_pause.set", "platform.admin", "free_auto_safety_pause", null, ADMIN),
158164
platform("GET", "/v1/admin/free-auto/usage", "platform.free_auto_usage.read", "platform.admin", "platform_report", null, ADMIN),
159165
platform("GET", "/v1/admin/mcp-registration", "platform.mcp_registration.read", "platform.admin", "platform_report", null, ADMIN),

‎ee/apps/den-api/src/env.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ const EnvSchema = z.object({
218218
OPENROUTER_MANAGEMENT_API_KEY: z.string().optional(),
219219
OPENROUTER_WORKSPACE_ID: z.string().optional(),
220220
STRIPE_SECRET_KEY: z.string().optional(),
221+
OPENAI_SAFETY_WEBHOOK_SECRET: z.string().optional(),
222+
OPENAI_SAFETY_READ_KEY: z.string().optional(),
221223
STRIPE_WEBHOOK_SECRET: z.string().optional(),
222224
STRIPE_INFERENCE_PRICE_ID: z.string().optional(),
223225
STRIPE_SEAT_PRICE_ID: z.string().optional(),
@@ -845,6 +847,7 @@ export const env = {
845847
auditSelfHostedEnabled: parsed.DEN_AUDIT_SELF_HOSTED_ENABLED === "true",
846848
corsHandledByEdge,
847849
openworkWebEnabled,
850+
openaiSafety: { webhookSecret: optionalString(parsed.OPENAI_SAFETY_WEBHOOK_SECRET), readKey: optionalString(parsed.OPENAI_SAFETY_READ_KEY) },
848851
inferenceFree: readFreeInferenceConfig(process.env),
849852
inferenceProxyBaseUrl: optionalString(parsed.GATEWAY_PROXY_BASE_URL) ?? "http://127.0.0.1:8791",
850853
modelsPublicBaseUrl: gatewayDeployment.modelsPublicBaseUrl ?? optionalString(parsed.GATEWAY_PROXY_BASE_URL) ?? "http://127.0.0.1:8791",

0 commit comments

Comments
 (0)