# AI Risks And Assurance

## AI Risks And Mitigations

### AI Request Guardrails In CLI (Before Data Leaves Machine)

| Risk | Automatic Handling In git-lrc | Where Implemented |
| --- | --- | --- |
| Sending too much code context | CLI sends selected diff scope instead of full repository by default | [internal/appcore/review_runtime.go](/content/livereview/git-lrc/docs/security/internal/appcore/review_runtime.go), [docs/LRC_README.md](/content/livereview/git-lrc/docs/security/docs/LRC_README/index.html) |
| Unsafe payload handling | Diff is wrapped in zip and encoded for transport in fixed request shape | [internal/reviewapi/helpers.go](/content/livereview/git-lrc/docs/security/internal/reviewapi/helpers.go), [internal/reviewmodel/types.go](/content/livereview/git-lrc/docs/security/internal/reviewmodel/types.go) |
| Oversized request behavior | Size-limit paths and 413 handling are enforced in review flow | [internal/appcore/review_runtime.go](/content/livereview/git-lrc/docs/security/internal/appcore/review_runtime.go) |
| Redirect-based credential leakage | HTTP redirect policy restricts cross-host redirect following | [network/http_client.go](/content/livereview/git-lrc/docs/security/network/http_client.go) |
| Insecure update transport | Self-update network paths enforce HTTPS endpoints | [network/selfupdate_operations.go](/content/livereview/git-lrc/docs/security/network/selfupdate_operations.go) |
| Secret disclosure in setup errors | Connector/setup error bodies redact submitted key material | [setup/connectors.go](/content/livereview/git-lrc/docs/security/setup/connectors.go), [setup/connectors_test.go](/content/livereview/git-lrc/docs/security/setup/connectors_test.go) |
| Local credential file exposure | Config file writes use restricted permission handling and atomic write paths | [storage/files.go](/content/livereview/git-lrc/docs/security/storage/files.go), [storage/files_test.go](/content/livereview/git-lrc/docs/security/storage/files_test.go) |

### AI Response Guardrails (Where They Run)

Deep model input/output sanitization is implemented in the LiveReview service. git-lrc transports review payloads and renders results, while LiveReview applies preflight and postflight sanitization for model ingress and egress.

Service-side references:

- [../LiveReview/internal/aisanitize/sanitizer.go](/content/livereview/git-lrc/docs/LiveReview/internal/aisanitize/sanitizer.go)
- [../LiveReview/internal/aisanitize/markdown.go](/content/livereview/git-lrc/docs/LiveReview/internal/aisanitize/markdown.go)
- [../LiveReview/internal/aiconnectors/connector.go](/content/livereview/git-lrc/docs/LiveReview/internal/aiconnectors/connector.go)
- [../LiveReview/docs/security/llm_output_sanitization.md](/content/livereview/git-lrc/docs/LiveReview/docs/security/llm_output_sanitization/index.html)

### Prompt Injection Through Code/Comments

Risk: malicious comments or diff content can influence AI output.

Current handling:

- CLI minimizes what is sent by default (selected diff scope only).
- Teams can point git-lrc to self-hosted LiveReview deployments to keep inference and policy enforcement in their own infrastructure.
- LiveReview applies input and output sanitization automatically before and after model calls.

### Insecure Suggestions

Risk: model output can contain insecure recommendations.

Current handling:

- Output remains advisory and requires human review before merge.
- Teams can enforce CI and branch protection policy in their VCS.

### AI Guardrail Verification

Relevant verification references:

- [setup/connectors_test.go](/content/livereview/git-lrc/docs/security/setup/connectors_test.go)
- [storage/files_test.go](/content/livereview/git-lrc/docs/security/storage/files_test.go)
- [../LiveReview/internal/aisanitize/postflight_test.go](/content/livereview/git-lrc/docs/LiveReview/internal/aisanitize/postflight_test.go)
- [../LiveReview/internal/aisanitize/markdown_test.go](/content/livereview/git-lrc/docs/LiveReview/internal/aisanitize/markdown_test.go)
- [../LiveReview/internal/api/unified_processor_v2_post_sanitize_test.go](/content/livereview/git-lrc/docs/LiveReview/internal/api/unified_processor_v2_post_sanitize_test.go)

## Automated Security Checks

| Workflow | Badge | What It Checks | Trigger | What It Guarantees | What It Does Not Guarantee |
| --- | --- | --- | --- | --- | --- |
| gitleaks |  | Secret pattern scanning in repository history/content | Pull request, push, manual | Detects many leaked credential patterns early | Cannot guarantee zero secret exposure or catch every custom secret format |
| osv-scanner |  | Dependency vulnerability scan using OSV database | Pull request, push, manual | Detects known vulnerable dependencies in scan scope | Cannot detect unknown (0-day) vulnerabilities |
| govulncheck |  | Go package vulnerability analysis | Pull request, push, manual | Detects known Go vulnerability matches | Cannot guarantee all runtime exploit paths are covered |
| Semgrep |  | Static analysis for security patterns | Pull request, push, scheduled, manual | Detects many common code-level security anti-patterns | Cannot prove absence of logic flaws or business-logic abuse |
| SBOM |  | Software bill of materials generation (Syft) | Release publish, push (dependency-relevant files), manual | Produces auditable component inventory for releases | Does not by itself prove component safety |

## SBOM And Dependency Transparency

- Latest releases: [git-lrc latest release](https://github.com/HexmosTech/git-lrc/releases/latest)
- SBOM workflow: [sbom.yml workflow](https://github.com/HexmosTech/git-lrc/actions/workflows/sbom.yml)

On release publication, SBOM JSON artifacts are generated and uploaded to release assets for dependency audit and procurement review.

## Security Refactor Evidence (Storage And Network Split)

git-lrc completed a large code organization refactor that separates local persistence logic and outbound HTTP logic into dedicated modules.

- Storage operation inventory: [storage/storage_status.md](/content/livereview/git-lrc/docs/security/storage/storage_status/index.html)
- Network operation inventory: [network/network_status.md](/content/livereview/git-lrc/docs/security/network/network_status/index.html)

Why this matters:

1. File and SQLite operations are reviewed in one inventory for local data-at-rest risk.
2. Outbound HTTP operations are reviewed in one inventory for data-in-transit risk.
3. Changes to storage or network behavior can be audited by checking status docs during code review.

## Known Limits

- Automated scanners reduce risk but do not guarantee absence of vulnerabilities.
- If git-lrc points to a remote LiveReview deployment, review payloads are transmitted to that deployment.
- Data retention and model-training settings are determined by the selected LiveReview server deployment.

## Supported Versions

Security fixes are prioritized on currently supported, actively maintained releases. Upgrade to the latest release to receive the most recent security improvements.

## Where To Verify

- Workflow definitions: [git-lrc workflows](https://github.com/HexmosTech/git-lrc/tree/main/.github/workflows)
- Storage operations inventory: [storage/storage_status.md](/content/livereview/git-lrc/docs/security/storage/storage_status/index.html)
- Network operations inventory: [network/network_status.md](/content/livereview/git-lrc/docs/security/network/network_status/index.html)
