You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The agent makes security-sensitive external API calls to GitLab, Jira, and Copilot/LLM providers, as well as performs critical operations like git push, MR comment posting, and approval gate decisions. Currently, there is structured logging via structlog but no dedicated audit trail for security-sensitive operations.
Without audit logging, we cannot:
Detect unauthorized API calls or suspicious patterns
Demonstrate compliance with security logging standards (OWASP A09, SOC 2)
Track which actor triggered which external action
Correlate audit events back to originating webhooks or poll cycles
Business Context
Why now? This is item #7 from the Recommended Hardening list in docs/wiki/security-model.md. As the agent operates in production environments with access to GitLab repositories, Jira projects, and LLM APIs via sensitive tokens (GITLAB_TOKEN, JIRA_API_TOKEN, GITHUB_TOKEN), we need visibility into security-sensitive operations.
Impact of not solving:
No forensic trail if tokens are compromised
Cannot detect malicious webhook replay attacks
Cannot prove compliance during security audits
Limited ability to investigate customer-reported issues involving agent actions
OWASP Mapping: This addresses A09:2021 – Security Logging and Monitoring Failures.
Success Metrics
Coverage: 100% of external API calls (GitLab, Jira, Copilot SDK) emit audit log entries
Traceability: Every audit entry includes correlation ID linking back to originating webhook/poll event
Searchability: Audit logs can be queried by actor, action, target, timestamp
Performance: Audit logging adds <5ms overhead per operation
Zero data loss: Audit entries are never dropped (even if external sink is unavailable)
As a security engineer I want to query audit logs for all GitLab API calls made by the agent in the last 24 hours So that I can investigate whether a token was compromised and identify affected resources
Acceptance Criteria:
Audit log entries include: timestamp (ISO 8601 with timezone), actor (webhook event ID or poll cycle ID), action (e.g., gitlab.api.post_mr_comment), target (e.g., project_id=123, mr_iid=45), outcome (success/failure), correlation_id
Logs are queryable by time range, action type, target resource
Failed operations are logged with error classification (e.g., auth_failure, rate_limit, network_error)
As a compliance auditor I want to review all webhook authentication successes and failures So that I can verify that only valid HMAC-authenticated requests are processed
Acceptance Criteria:
Audit log entry for every webhook POST to /webhook endpoint
Entry includes: HMAC validation result (valid or invalid), source IP (if available from headers), project_id (if valid), rejection reason (if invalid)
Invalid HMAC attempts are logged with full context (timestamp, IP, project_id if parseable)
US-3: Operator traces coding command execution
As a platform operator I want to trace all /copilot command executions from MR comment to git push So that I can debug failed coding workflows and verify approval gate enforcement
Acceptance Criteria:
Audit trail for: MR comment received (/copilot command), coding task started (K8s Job or local executor), patch generated, patch validated, git push executed, approval gate decision (approved/rejected)
As a DevOps engineer I want to configure where audit logs are sent (stdout, file, external SIEM) So that I can integrate audit logs with our existing security monitoring infrastructure
Problem
The agent makes security-sensitive external API calls to GitLab, Jira, and Copilot/LLM providers, as well as performs critical operations like git push, MR comment posting, and approval gate decisions. Currently, there is structured logging via structlog but no dedicated audit trail for security-sensitive operations.
Without audit logging, we cannot:
Business Context
Why now? This is item #7 from the Recommended Hardening list in
docs/wiki/security-model.md. As the agent operates in production environments with access to GitLab repositories, Jira projects, and LLM APIs via sensitive tokens (GITLAB_TOKEN,JIRA_API_TOKEN,GITHUB_TOKEN), we need visibility into security-sensitive operations.Impact of not solving:
OWASP Mapping: This addresses A09:2021 – Security Logging and Monitoring Failures.
Success Metrics
User Stories
US-1: Security Engineer investigates suspicious activity
As a security engineer
I want to query audit logs for all GitLab API calls made by the agent in the last 24 hours
So that I can investigate whether a token was compromised and identify affected resources
Acceptance Criteria:
gitlab.api.post_mr_comment), target (e.g.,project_id=123, mr_iid=45), outcome (success/failure), correlation_idauth_failure,rate_limit,network_error)US-2: Compliance auditor verifies authentication events
As a compliance auditor
I want to review all webhook authentication successes and failures
So that I can verify that only valid HMAC-authenticated requests are processed
Acceptance Criteria:
/webhookendpointvalidorinvalid), source IP (if available from headers), project_id (if valid), rejection reason (if invalid)US-3: Operator traces coding command execution
As a platform operator
I want to trace all
/copilotcommand executions from MR comment to git pushSo that I can debug failed coding workflows and verify approval gate enforcement
Acceptance Criteria:
/copilotcommand), coding task started (K8s Job or local executor), patch generated, patch validated, git push executed, approval gate decision (approved/rejected)correlation_idUS-4: DevOps configures audit log destination
As a DevOps engineer
I want to configure where audit logs are sent (stdout, file, external SIEM)
So that I can integrate audit logs with our existing security monitoring infrastructure
Acceptance Criteria:
AUDIT_LOG_DESTINATION(env var) with values:stdout(default),file,syslog,httpfile:AUDIT_LOG_FILE_PATHspecifies target file (supports log rotation)http:AUDIT_LOG_HTTP_ENDPOINTspecifies target URL (JSON POST)Acceptance Criteria (Overall)
AC-1: External API Call Coverage
gitlab.api.get_mr_detailsgitlab.api.get_mr_diffgitlab.api.post_mr_note(review comments)gitlab.api.post_commit_discussiongitlab.api.get_project_infogitlab.api.clone_repo(git clone via URL)gitlab.api.push_branch(git push)jira.api.get_issuejira.api.transition_issuejira.api.add_commentjira.api.search_issuescopilot.sdk.review_request(review mode)copilot.sdk.coding_request(coding mode)copilot.sdk.response_receivedAC-2: Authentication Events
AC-3: Sensitive Operations
/copilotcommand executions logged with: command, project_id, mr_iid, initiator (comment author), correlation_idAC-4: Log Entry Schema
Each audit log entry includes:
{ "timestamp": "2025-01-15T14:32:15.123Z", "event_type": "audit", "action": "gitlab.api.post_mr_note", "actor": { "type": "webhook_event" | "poll_cycle" | "admin_action", "id": "<correlation_id>" }, "target": { "resource_type": "merge_request", "project_id": 123, "mr_iid": 45 }, "outcome": "success" | "failure", "error": "<error_classification if failure>", "correlation_id": "<UUID>", "service": "gitlab-copilot-agent" }AC-5: Configuration
AUDIT_LOG_ENABLEDenv var (default:true)AUDIT_LOG_DESTINATIONenv var (values:stdout,file,http)AUDIT_LOG_FILE_PATHenv var (if destination=file)AUDIT_LOG_HTTP_ENDPOINTenv var (if destination=http)AC-6: Correlation IDs
correlation_id(UUID) at ingress (webhook.py)correlation_idper poll iterationcorrelation_idpropagated through: task execution, K8s Job pods (via env var), Redis results, git operations, API callscorrelation_idcorrelation_idincluded in OpenTelemetry trace contextAC-7: Performance & Reliability
audit_log_entries_totalcounter (labels: action, outcome)audit_log_sink_errors_totalcounter (labels: destination)Scope
In Scope
/copilotcommands, approval gates)Out of Scope
Dependencies
telemetry.py)Risks
correlation_idcorrelation_idto all Task models and executor methodsReferences
docs/wiki/security-model.md(item feat(jira): Jira poller and config #7 in Recommended Hardening)telemetry.py)Implementation Notes
Suggested approach (for Developer Agent):
audit_logger.pymodule withAuditLoggerclasscorrelation_idfield to webhook/poll event modelswebhook.pyfor HMAC validationcorrelation_idthrough Task models and executor methodsconfig.pymetrics.pyEstimated effort: Medium (3-5 PRs, stack structure recommended)
Priority: High (security hardening item)