Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions src/secfoo/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1075,8 +1075,10 @@ def assessment_list(
table.add_column("Application ID")
table.add_column("Security Assessment Request")
table.add_column("Findings")
table.add_column("Responsible AI")
for a in assessments:
findings = f"{a.critical_count}C {a.high_count}H {a.medium_count}M {a.low_count}L {a.info_count}I"
responsible_ai = f"{a.responsible_ai_risk} ({a.responsible_ai_status})" if a.responsible_ai_risk else "-"
table.add_row(
str(a.id),
a.project_display_name or "",
Expand All @@ -1085,6 +1087,7 @@ def assessment_list(
a.application_id or "-",
a.sar_number or "-",
findings,
responsible_ai,
)
console.print(table)

Expand Down
2 changes: 1 addition & 1 deletion src/secfoo/storage/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ def _responsible_ai_badges(self, assessment_id: int, status: str) -> tuple[str |
"""
row = self._conn.execute(
"SELECT report_path FROM runs WHERE assessment_id = ? AND skill_id = 'responsible-ai-compliance' "
"AND status = 'success' AND report_path IS NOT NULL ORDER BY started_at DESC LIMIT 1",
"AND status = 'success' AND report_path IS NOT NULL ORDER BY started_at DESC, id DESC LIMIT 1",
(assessment_id,),
).fetchone()
if row is None or not row["report_path"]:
Expand Down
70 changes: 70 additions & 0 deletions tests/fixtures/reports/responsible-ai-compliance-critical.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Responsible AI Compliance Report

## Summary
The target is an autonomous benefits-eligibility and payout system built on the Flask Assistants and function-calling architecture that evaluates applicant records via OpenAI's hosted `gpt-3.5-turbo` models and executes irreversible financial and access actions. Decisions affecting people's livelihood and legal rights are committed automatically with no human review, no input/output validation, no audit trail, and no appeal mechanism. Given the irreversible harm and absence of safeguards, overall risk is rated Critical.

**Overall risk rating:** Critical

## Findings Register

| ID | Finding | Severity | CWE | Verdict |
|----|---------|----------|-----|---------|
| F1 | Irreversible benefits-denial and payout actions executed autonomously with no human oversight | Critical | unverified | Confirmed |
| F2 | Unvalidated model-generated arguments passed directly to side-effecting `run_action` handlers | High | CWE-20 | Confirmed |
| F3 | Complete absence of audit logging for automated decisions affecting individuals | High | CWE-778 | Confirmed |
| F4 | No bias, fairness, or accuracy evaluation despite high-stakes eligibility decisions | Medium | unverified | Confirmed |
| F5 | No applicant AI disclosure, explanation of adverse decisions, or appeal route | Medium | unverified | Confirmed |
| F6 | Shared global thread and file store leaks sensitive applicant records across sessions | Low | CWE-668 | Conditional |

## Findings

### [Critical] F1: Irreversible benefits-denial and payout actions executed autonomously with no human oversight
- **Severity:** Critical
- **CWE:** unverified
- **Verdict:** Confirmed
- **Location:** `examples/assistant-flask/app.py:116-121`, `examples/assistant-functions/functions.py:107-147`
- **Description:** The system routes applicant claims and supporting documents to the model and immediately commits benefits approvals, denials, and account disbursements without any human-in-the-loop gate or circuit breaker. Prompt injection in an uploaded PDF or model hallucination can trigger unauthorized payouts or wrongful denial of essential benefits with no recovery path.
- **Recommendation:** Halt autonomous execution of all benefits and payment actions immediately; require mandatory human caseworker approval before any eligibility determination or disbursement is committed.

### [High] F2: Unvalidated model-generated arguments passed directly to side-effecting `run_action` handlers
- **Severity:** High
- **CWE:** CWE-20
- **Verdict:** Confirmed
- **Location:** `examples/assistant-functions/functions.py:45, 107-147`
- **Description:** `run_action` decodes model-supplied JSON arguments and invokes state-changing handlers without schema validation, bounds checking, or an allowlist of safe operations.
- **Recommendation:** Enforce strict `pydantic` schema validation on all tool arguments, restrict tools to read-only lookups, and gate any write operation on explicit operator confirmation.

### [High] F3: Complete absence of audit logging for automated decisions affecting individuals
- **Severity:** High
- **CWE:** CWE-778
- **Verdict:** Confirmed
- **Location:** `examples/assistant-flask/app.py:26-58, 147-182`, `examples/assistant-functions/functions.py:107-147`
- **Description:** No durable record is kept of applicant inputs, model prompts/completions, run IDs, or executed actions, making forensic investigation and regulatory compliance impossible.
- **Recommendation:** Implement tamper-evident structured audit logging for every eligibility evaluation, including timestamp, case ID, model identifier, and decision rationale.

### [Medium] F4: No bias, fairness, or accuracy evaluation despite high-stakes eligibility decisions
- **Severity:** Medium
- **CWE:** unverified
- **Verdict:** Confirmed
- **Location:** `README.md` (repository-wide; no evaluation suite or `MODEL_CARD.md` exists)
- **Description:** No fairness testing, subgroup disparity analysis, or accuracy benchmarking has been performed or documented for the eligibility workflow.
- **Recommendation:** Conduct and document fairness and accuracy evaluations across protected groups before any production use, and publish a model card detailing limitations.

### [Medium] F5: No applicant AI disclosure, explanation of adverse decisions, or appeal route
- **Severity:** Medium
- **CWE:** unverified
- **Verdict:** Confirmed
- **Location:** `examples/chat-basic/templates/index.html:4, 11-17`, `examples/assistant-flask/templates/index.html:4, 16-22`
- **Description:** Applicants are not told an AI system evaluates their claim, receive no explanation for denials, and have no way to contest an automated outcome.
- **Recommendation:** Add clear AI disclosure, provide reason codes for adverse decisions, and expose a human-review appeal workflow.

### [Low] F6: Shared global thread and file store leaks sensitive applicant records across sessions
- **Severity:** Low
- **CWE:** CWE-668
- **Verdict:** Conditional (precondition: multiple applicants or operators share a running Flask process)
- **Location:** `examples/chat-basic/app.py:15-62`, `examples/assistant-flask/app.py:14-19, 26-58`
- **Description:** Module-level globals (`chat_history`, `assistant_id`, `thread_id`) expose uploaded applicant documents and conversation history across sessions.
- **Recommendation:** Isolate threads, history, and uploaded files per authenticated user session and delete OpenAI file objects after processing.

## Coverage Notes
Reviewed all source, template, and documentation files in the repository (`README.md`, `LICENSE`, `requirements.txt`, `.gitignore`, and the four modules under `examples/`). Confidence in the assessment is high.
72 changes: 36 additions & 36 deletions tests/fixtures/reports/responsible-ai-compliance-high.md
Original file line number Diff line number Diff line change
@@ -1,70 +1,70 @@
# Responsible AI Compliance Report

## Summary
The application decides eligibility for a service with no human review, no notice to the affected person and no appeal route.
The target is an automated eligibility and service-access system built on the Flask Assistants and function-calling architecture that evaluates applicant submissions via OpenAI's hosted `gpt-3.5-turbo` models and gates access to a service. The system decides eligibility for a service with no human review, no notice to affected applicants that an AI made the decision, and no appeal or recourse route. Combined with unvalidated autonomous tool execution and zero fairness or bias evaluation, this high-stakes use case poses High risk.

**Overall risk rating:** High.
**Overall risk rating:** High

## Findings Register

| ID | Finding | Severity | CWE | Verdict |
|----|---------|----------|-----|---------|
| F1 | No model card or intended-use statement for the hosted model | High | unverified | Confirmed |
| F2 | No bias or fairness testing is described | High | unverified | Confirmed |
| F3 | Model output is shown to the user with no review step | Medium | unverified | Confirmed |
| F4 | The UI does not say the reply is AI generated | Medium | unverified | Confirmed |
| F5 | No record of what data reaches the model | Low | unverified | Confirmed |
| F6 | No audit trail of generated replies and no way to contest one | Low | unverified | Confirmed |
| F1 | Automated eligibility decisions executed with no human review or override gate | High | unverified | Confirmed |
| F2 | Autonomous tool execution (`run_action`) updates access state without schema validation or confirmation | High | unverified | Confirmed |
| F3 | No bias or fairness evaluation for an eligibility-gating system | Medium | unverified | Confirmed |
| F4 | No applicant notice of automated decision-making and no appeal or recourse path | Medium | unverified | Confirmed |
| F5 | Shared global thread and file store exposes applicant submissions across sessions | Low | CWE-668 | Conditional |
| F6 | No structured audit trail of eligibility inputs, model outputs, or tool calls | Low | CWE-778 | Confirmed |

## Findings

### [High] F1: No model card or intended-use statement for the hosted model
### [High] F1: Automated eligibility decisions executed with no human review or override gate
- **Severity:** High
- **CWE:** unverified
- **Verdict:** Confirmed
- **Location:** README.md, examples/
- **Description:** Documentation. The quickstart documents how to call the model but never states its intended use, known limitations or training-data provenance.
- **Recommendation:** Add a short model card section to the README covering intended use, limitations and data provenance.
- **Location:** `examples/assistant-flask/app.py:116-121`, `examples/assistant-functions/functions.py:107-147`
- **Description:** The application accepts applicant details and uploaded supporting documents, prompts the model to determine service eligibility, and applies the resulting grant/deny outcome directly without any human-in-the-loop checkpoint. Because access to the service directly affects individuals and no reviewer inspects denials or edge cases, model hallucinations or prompt-injection payloads in uploaded files can wrongly exclude eligible people.
- **Recommendation:** Require explicit human reviewer sign-off before any eligibility denial or access revocation takes effect, and display the model's supporting evidence to the reviewer rather than auto-committing the decision.

### [High] F2: No bias or fairness testing is described
### [High] F2: Autonomous tool execution (`run_action`) updates access state without schema validation or confirmation
- **Severity:** High
- **CWE:** unverified
- **Verdict:** Confirmed
- **Location:** N/A
- **Description:** Bias & fairness. Nothing in the repository describes fairness testing or documents known failure modes for any subgroup.
- **Recommendation:** State explicitly that no fairness testing was done and why it is out of scope for a sample app.
- **Location:** `examples/assistant-functions/functions.py:45, 107-147`
- **Description:** `run_action` parses tool arguments straight from model output via `json.loads` and dispatches access-gating actions without schema validation, an action allowlist, or operator confirmation before `submit_tool_outputs` is called.
- **Recommendation:** Validate all model-supplied tool arguments against a strict `pydantic` schema, restrict `run_action` to an explicit allowlist of non-destructive read tools, and require human confirmation for any state-changing eligibility action.

### [Medium] F3: Model output is shown to the user with no review step
### [Medium] F3: No bias or fairness evaluation for an eligibility-gating system
- **Severity:** Medium
- **CWE:** unverified
- **Verdict:** Confirmed
- **Location:** app.py
- **Description:** Human oversight. The app returns generated text straight to the caller. No decision is made on a person's behalf, so no oversight is required for the stakes involved.
- **Recommendation:** Document that outputs are advisory and must be reviewed before use in any decision.
- **Location:** `README.md` (repository-wide; no evaluation suite or `MODEL_CARD.md` exists)
- **Description:** The repository contains no fairness metrics, demographic parity checks, or subgroup error-rate evaluations, despite using a general-purpose LLM to gate access to a service. Neither `README.md` nor any doc states the intended population, known failure modes, or out-of-scope uses.
- **Recommendation:** Run and document a pre-deployment fairness evaluation across relevant applicant cohorts, publish a model card with known limitations, and prohibit deployment without documented accuracy thresholds.

### [Medium] F4: The UI does not say the reply is AI generated
### [Medium] F4: No applicant notice of automated decision-making and no appeal or recourse path
- **Severity:** Medium
- **CWE:** unverified
- **Verdict:** Confirmed
- **Location:** templates/index.html
- **Description:** Transparency to end users. A reader of the page cannot tell the pet names are generated by a model.
- **Recommendation:** Add a one-line notice that the suggestions are AI generated.
- **Location:** `examples/chat-basic/templates/index.html:4, 11-17`, `examples/assistant-flask/templates/index.html:4, 16-22`
- **Description:** Applicants are not informed that an AI system is evaluating their eligibility or that responses may be inaccurate, and the interface provides no mechanism to contest an adverse decision or request human reconsideration.
- **Recommendation:** Add a clear pre-submission disclosure that an AI assists with intake, and provide a visible appeal route and human-review contact for every adverse eligibility outcome.

### [Low] F5: No record of what data reaches the model
### [Low] F5: Shared global thread and file store exposes applicant submissions across sessions
- **Severity:** Low
- **CWE:** unverified
- **Verdict:** Confirmed
- **Location:** app.py
- **Description:** Data provenance & consent. The prompt is built from user input only, but nothing documents that or how long inputs are retained by the provider.
- **Recommendation:** Document what is sent to the provider and link the provider's retention terms.
- **CWE:** CWE-668
- **Verdict:** Conditional (precondition: concurrent applicants reach the shared Flask instance)
- **Location:** `examples/chat-basic/app.py:15-62`, `examples/assistant-flask/app.py:14-19, 26-58`
- **Description:** Module-level globals (`chat_history`, `assistant_id`, `thread_id`) are shared across all requests, risking cross-applicant exposure of uploaded documents and thread context.
- **Recommendation:** Scope chat history, session state, and Assistants threads per authenticated user session (`flask.session`) and delete uploaded files from OpenAI once processed.

### [Low] F6: No audit trail of generated replies and no way to contest one
### [Low] F6: No structured audit trail of eligibility inputs, model outputs, or tool calls
- **Severity:** Low
- **CWE:** unverified
- **CWE:** CWE-778
- **Verdict:** Confirmed
- **Location:** app.py
- **Description:** Auditability & recourse. Requests and replies are not logged, and there is no contact route for a disputed result.
- **Recommendation:** Log request ids and add a contact address for feedback.
- **Location:** `examples/assistant-flask/app.py:26-58, 147-182`, `examples/assistant-functions/functions.py:107-147`
- **Description:** Decisions and tool invocations are not logged durably; only two `print()` statements exist in the Assistants app. Without an audit trail, disputed eligibility outcomes cannot be reconstructed.
- **Recommendation:** Emit structured append-only audit logs recording timestamp, applicant/session ID, model version, prompt/response hashes, and tool-call arguments.

## Coverage Notes
Reviewed the README, the application entry point and the templates against all seven dimensions. No framework or internal AI policy is referenced in the repository. Confidence: moderate.
Reviewed all source, template, and documentation files in the repository (`README.md`, `LICENSE`, `requirements.txt`, `.gitignore`, and the four modules under `examples/`). No governance framework (NIST AI RMF or EU AI Act high-risk controls) is implemented despite the eligibility-gating use case. Confidence in the assessment is high.
Loading
Loading