Repository navigation
Promptise Foundry 1.7.1
Three security fixes: approval request ids are now single-use as the docs said, a classifier rule that raises no longer lets a call through, and API keys and JWTs can be revoked while an MCP server runs.
Upgrade notes
- A second decision for the same approval request is refused.
QueueApprovalHandler.submit_decision()raisesApprovalReplayErrorfor it (aKeyErrorsubclass, so code that catchesKeyErrorkeeps working); before, it was ignored without a word.PendingApprover.decide()still returnsFalse, and now logs a warning. - A classifier deny rule whose predicate raises now denies the call, and an allow rule that raises sends the call to the fallback handler instead of letting the read-only check or the LLM classifier decide it. Fix or remove rules that raise.
- The HTTP auth gate (
MCPServer(require_auth=True)) callsaverify_token()when the provider has one, and a verifier that raises now rejects the request with401instead of failing it with an error. A custom provider with onlyverify_token()works as before.
Security
- Approval: request ids are single-use -- the docs said request ids are "tracked to prevent replay attacks", but the agent's gate only wrote them to a set nobody read, so a second decision for the same id was accepted. Each request id now takes exactly one decision, and a second one is refused and logged on the
promptise.approvallogger (promptise.server.approvalon an MCP server): the agent's gate andApprovalGateMiddlewaredeny the call without asking the reviewer again,QueueApprovalHandler.submit_decision()raisesApprovalReplayError,PendingApprover.decide()returnsFalseandapprovals_decideanswers that the request was already decided.WebhookApprovalHandlerignores a poll response whoserequest_idis another request's (a stale decision behind a fixedpoll_url, or a replayed one) and keeps polling; responses withoutrequest_idare accepted as before. On the approval service,verify_webhook_signature(..., replay_cache=RequestIdCache())rejects a signed request whoserequest_idalready passed;max_agealone still accepts a copy until the timestamp is too old. Decided ids are kept in the newpromptise.approval.RequestIdCache, in memory, for the approvaltimeout(twicemax_agefor signatures) and at most 10,000 at a time. See "Single-Use Request IDs" in docs/core/approval.md. - Approval classifier: a rule that raises no longer fails open -- an
ApprovalRulepredicate that raised counted as "no match", so a broken deny rule let through the calls it was written to stop: they went on to the allow rules, the read-only check or the LLM classifier. A deny rule that cannot be evaluated now denies the call (decided_by="classifier",trace.layer="deny_rule", the exception type in the reason), an ask rule that raises sends the call to the fallback handler, and an allow rule that raises never allows: the call goes straight to the fallback (trace.layer="error"). Each case logs a warning and counts instats.errors.ApprovalRule.evaluate()raises the newRuleEvaluationError;ApprovalRule.matches()keeps returningFalse. See "A rule that raises" in docs/core/approval-classifier.md. - MCP server: API keys can be revoked without a restart --
APIKeyAuthcopied its keys when it was created, so a leaked key stayed valid until the server restarted. With akeysdict,revoke_key(key)andadd_key(key, config)change the keys for the next request.keys=also takes a callable (sync or async) that returns the keys valid right now, and the newlookup=takes a callable (sync or async) that receives the presented key and returns its config, orNonefor an unknown or revoked key, so the keys can live in a database or cache. A callable that raises rejects the request. See "Revoking and adding keys while the server runs" in docs/mcp/server/auth-security.md. - MCP server: JWTs can be revoked before they expire --
JWTAuth,AsymmetricJWTAuthandJwksAuthaccepted a token until itsexp. They now take an optional deny list, checked on every request (cached tokens included):revoked_jtis=[...],revoked_subjects=[...],revoke(jti, subject=..., until=...)andunrevoke(...)at runtime, andis_revoked=, a hook (sync or async) that gets the verified claims and returnsTrueto reject the token, for a deny list shared between replicas.until(normally the token'sexp) drops an entry once the token has expired. A revoked token is rejected withToken has been revoked; a hook that raises rejects the token.create_token()does not add ajti, so pass one in the payload to revoke single tokens, or revoke by subject. All four providers getaverify_token(), which runs async stores and hooks; the syncverify_token()rejects the credential when one is async. See "Revoking tokens" in docs/mcp/server/auth-security.md.
Changed
- Docs: the ConversationFlow, ModelLike and default system prompt pages name their API in the page title and headings (
ConversationFlow,ModelLike,DEFAULT_SYSTEM_PROMPT), and the ModelLike page says it has four forms (it said three). No anchor other pages link to changed. - Docs: the approval, approval classifier, approval gates, auth and deployment pages describe exactly what the fixes above enforce, and the identity guide links to token revocation.
pip install -U promptise