8000 Automation of Keycloak Security Vulnerability reports by abstractj · Pull Request #52 · keycloak/keycloak-github-bot · GitHub
[go: up one dir, main page]

Skip to content

Automation of Keycloak Security Vulnerability reports - #52

Merged
stianst merged 4 commits into
keycloak:mainfrom
abstractj:keycloak-security
Feb 20, 2026
Merged

stianst merged 4 commits into
keycloak:mainfrom
abstractj:keycloak-security

Conversation

@abstractj
Copy link
Copy Markdown
Contributor

This closes https://github.com/keycloak/keycloak-security-team/issues/3

Requirements to Test

To test this PR, you must configure the following credentials. These are required because the new workflow acts as a bridge, relying on live integration with these external services to orchestrate the security lifecycle.

Overview:

The following diagram illustrates how the bot sits between the users and external services

graph TD
    Researcher((External Researcher)) -- "Sends Reports" --> Gmail[Gmail Service]
    
    subgraph Integration Dependencies
        Bot[Keycloak Bot] <-- "Polls & Sends Emails (Requires Gmail Creds)" --> Gmail
        Bot <-- "Syncs CVE Data (Requires Jira PAT)" --> Jira[Red Hat Jira]
    end
    
    Bot -- "Creates & Updates Issues" --> GitHub[GitHub Repository]
    Maintainer((Maintainer)) -- "ChatOps Commands" --> GitHub
Loading
  • Gmail Credentials: You must configure a Client ID, Client Secret, and Refresh Token.

    • Note: Service Accounts are no longer supported. You must use a standard OAuth2 flow with a dedicated user account (e.g., bot@keycloak.org) to generate a long-lived Refresh Token.
  • Jira Credentials: A Personal Access Token (PAT) is required to sync CVE data from the Red Hat Jira API.

Overview

This PR introduces a security workflow integration for the Keycloak GitHub Bot. It enables the bot to act as a bridge between external security reports (via email), internal tracking (Red Hat Jira), and our private GitHub repository.

The goal is to automate the lifecycle of security vulnerabilities: receiving reports, assigning CVEs, synchronizing official "Flaw" descriptions from Jira, and allowing maintainers to communicate with external researchers from GitHub comments.

Flow Overview

sequenceDiagram
    participant Ext as External Researcher
    participant Email as Security Mailing List
    participant Bot as Keycloak Bot
    participant GH as GitHub Issue
    participant Jira as Red Hat Jira

    Note over Ext, GH: 1. Security Reporting Flow
    Ext->>Email: Sends Vulnerability Report
    Email->>Bot: Forwards Email
    Bot->>GH: Creates New Issue (status/triage)

    Note over GH, Jira: 2. CVE Enrichment Flow (Scheduled)
    Jira->>Bot: CVE Data (Summary, Description)
    Bot->>GH: Syncs Title & Body (CVE-XXXX-YYYY)
    Bot->>GH: Adds label 'status/jira-synced'

    Note over GH, Ext: 3. ChatOps Flow
    GH->>Bot: Comment: /reply "Thanks for the report"
    Bot->>Email: Sends Reply
    Email->>Ext: Delivers Email
Loading

Key Features

1. E-mail sync

  • Monitors Gmail: The bot polls the keycloak-security Google Group for new unread emails.

  • Issue Creation: Automatically converts incoming security reports into GitHub issues labeled source/email and status/triage.

  • Thread Tracking: Replies to the same email thread are appended as comments to the existing GitHub issue, preserving context.

2. Jira Synchronization

  • Official Source of Truth: queries per hour the Red Hat Jira API for issues matching CVE-XXXX-YYYY patterns found in GitHub titles only if kind/cve label is assigned.

  • Sanitization: Updates the GitHub issue title and description with the official "Flaw" details from Jira, automatically stripping sensitive prefixes (e.g., EMBARGOED, rhbk/keycloak:) and internal metadata.

  • Idempotency: Marks issues as status/jira-synced to prevent redundant API calls.

3. CVE Management

  • Placeholder Updates: Detects emails from Product Security (SecAlert) assigning CVE IDs and automatically updates GitHub issue titles from CVE-TBD to the real ID (e.g., CVE-2026-1234).

  • Corrections: Supports updating CVE IDs if a correction email is received from a trusted source.

4. Commands

Maintainers can manage communication directly from the GitHub issue comments using slash commands.

Command Reference

Command Arguments Description
/reply keycloak-security [Body] Sends an email reply to the original reporter and the security mailing list.
/new secalert "Subject" [Body] Initiates a new private email thread with Red Hat Product Security (secalert@redhat.com), typically used to request CVE assignment.
/reply secalert [Body] Replies to an existing private thread with SecAlert. Requires a thread to have been started via /new secalert.

Example Usage:

@botname /reply keycloak-security
Thank you for the report. We have confirmed the issue and are working on a fix.
@botname /new secalert "CVE Assignment Request"
We have confirmed a vulnerability in the Admin Console. Please assign a CVE ID.

@abstractj
Copy link
Copy Markdown
Contributor Author

@keycloak/security on our next meeting I would like share the working demo with you for validation.

@abstractj
abstractj force-pushed the keycloak-security branch 8 times, most recently from 9a1ceb0 to 0d0c490 Compare February 6, 2026 22:49
Signed-off-by: Bruno Oliveira da Silva <bruno@abstractj.com>
This pull request introduces the possibility of uploading email
attachments to GitHub. In a separate commit in case we don't want this
feature considering the security trade-offs.

Enabling the bot to automatically upload files requires granting the
read/write permissions to contents which can be a double-edged sword in
terms of repository security.

Signed-off-by: Bruno Oliveira da Silva <bruno@abstractj.com>
Signed-off-by: Bruno Oliveira da Silva <bruno@abstractj.com>
…ty features

Signed-off-by: Bruno Oliveira da Silva <bruno@abstractj.com>
@ahus1 ahus1 left a comment
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this bot. It is a lot of functionality and code, which to me is a bit overwhelming.

  • I saw the demo, and that looked good.
  • I see a switch to disable this bot, which is also good.
  • Going forward, it would be good to have at least one more person, better two to be able to extend the bot. I'm volunteering to be one of those people.

@rmartinc rmartinc left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @abstractj! It's a nice and big bot! 😄 I reviewed it but not in detail. I have just checked the option to disable it is OK. So I would go with it and we can improve it later. We can disable it if it makes a lot of noise.

@sschu sschu left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also mostly looked at the demo which looked good to me.

@stianst
stianst merged commit 417d9b5 into keycloak:main Feb 20, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

0