# GHSA-224H-JMFQ-QC67: GitHub credentials are included in skills.sh search requests

- Database: GitHub
- Severity: CVSS 5.9 (Medium)
- Published: 2026-11-22
- Modified: 2026-11-22

## Affected versions

- ag2 (PyPI): from 0.12.0, through 1.3.3
- autogen (PyPI): from 0.12.0, through 0.14.1

## Description

# GitHub credentials are included in skills.sh search requests

## Summary

`SkillsClient` uses the same default headers for GitHub archive downloads and
skills.sh searches. Its constructor adds an `Authorization: Bearer ...` header
from `SkillsClientConfig.github_token` or the ambient `GITHUB_TOKEN` environment
variable. Consequently, calling `search()` sends that GitHub credential to
`https://skills.sh/api/search` as well.

This reproduces on main commit
`5125cb5dfcc99aa3c31ca248cb734c63628a99dd` (the checkout declares AG2 1.3.0).
The published `v1.3.0` tag contains the identical affected `client.py` blob
(`50e2edf9c79fcf5feaebdb5f0388da310163dc1f`). Earlier versions have not been
assessed, so the complete affected release range remains to be established.

The higher-level `SkillSearchToolkit` also uses `SkillsClient.search()`, so a
user can encounter this while discovering skills, without downloading one.

## Conditions and impact

- A GitHub token is configured through `github_token` or `GITHUB_TOKEN`.
- The application performs a skills.sh search using this client.
- The outgoing request contains the token, although the destination is a
  different service from the GitHub API for which it was configured.

This is an unintended credential disclosure to the search service. The
potential impact depends on the token's permissions. I have no evidence of
retention, access, or misuse by the receiving service, and did not test with a
real credential or contact that service during reproduction.

## Offline reproduction

Save the following as `reproduce.py`. It calls the public
`SkillsClient.search()` method using dummy credentials. RESPX intercepts the
real HTTPX request construction and rejects unmatched requests. It tests both
configuration and environment sources without sending traffic to an external
service.

```python
import asyncio
import os
from unittest.mock import patch

import httpx
import respx

from ag2.tools.skills.skill_search.client import SkillsClient
from ag2.tools.skills.skill_search.config import SkillsClientConfig


async def main():
    for source in ("config", "environment"):
        with patch.dict(os.environ, {"GITHUB_TOKEN": "dummy-env-token"}):
            config = SkillsClientConfig(github_token="dummy-config-token") if source == "config" else None
            client = SkillsClient(config)
        with respx.mock(assert_all_mocked=True, assert_all_called=True) as router:
            search = router.get("https://skills.sh/api/search").mock(
                return_value=httpx.Response(200, json={"skills": []})
            )
            await client.search("example")
            request = search.calls.last.request
            print(f"{source}: destination={request.url.host}, authorization_present={'authorization' in request.headers}")


asyncio.run(main())
```

Run from an affected checkout with its dependencies and RESPX installed:

```text
PYTHONPATH=. python /path/to/reproduce.py
```

Observed on the unmodified baseline:

```text
config: destination=skills.sh, authorization_present=True
environment: destination=skills.sh, authorization_present=True
```

Expected: both values are `False`; GitHub archive downloads should still receive
the configured credential.

## Proposed fix

Keep the resolved GitHub token separate from common headers. Construct the
download-specific headers in `download_skill()`, adding the token there only.
Use `httpx.Headers.setdefault()` so an explicitly supplied Authorization header
retains precedence and HTTP header names are handled case-insensitively.

This does not change the documented `SkillsClientConfig.headers` option: headers
explicitly supplied through that option still apply to every request. The fix
specifically isolates the automatically generated GitHub authentication header.
The shared header mapping is never mutated by a download.

Existing HTTPX cross-host redirect behavior continues to remove Authorization
when the archive request redirects to the separate download host.

The production change in `ag2/tools/skills/skill_search/client.py` is:

```diff
@@
-        token = cfg.github_token or os.environ.get("GITHUB_TOKEN")
-        if token:
-            self._headers["Authorization"] = f"Bearer {token}"
+        self._github_token = cfg.github_token or os.environ.get("GITHUB_TOKEN")
@@
         with tempfile.TemporaryDirectory() as tmp_dir:
             tar_path = Path(tmp_dir) / "skill.tar.gz"
             hash_obj = hashlib.sha256()
+            headers = httpx.Headers(self._headers)
+            if self._github_token:
+                headers.setdefault("Authorization", f"Bearer {self._github_token}")

             async with (
-                self._make_client(timeout=120) as client,
+                self._make_client(timeout=120, headers=headers) as client,
```

## Validation

- Unmodified baseline plus regression tests, Linux/Python 3.12.13:
  **2 failed, 146 passed, 2 skipped**. Only the two new token-isolation cases fail.
- Patched checkout, same environment and skills suite:
  **148 passed, 2 skipped**. Both skips are existing Windows-only interpreter
  lookup cases; no skip conditions were added or changed.
- Patched checkout, Windows/Python 3.12.1: all **5 new cases pass**.
- Independent transport check: using the public API URL constant to direct
  requests to a local HTTP server, the server received the exact dummy Bearer
  token from each source with the unmodified client. Neither source sent it
  after the fix. This check uses real sockets, without mocking HTTPX or its
  transport. It does not send credentials to a real external service.
- Tests cover explicit-token precedence over the environment token, environment
  fallback, no-token operation, custom headers, actual archive extraction and
  installation, search after download, and cross-host redirects.
- Repository-wide Ruff check and format check pass with Ruff 0.16.10.
- Spelling checks for the changed files and whitespace checks pass.

The complete optional-provider/LLM matrix and hosted CI have not run for this
private candidate. The supplied test runs make no live provider calls.

## Coordination

The patch and tests are prepared locally, and I am happy to contribute the fix
and respond to review. No public issue, branch, or PR has been published.
Please advise whether you prefer a private advisory patch or another private
review workflow before public disclosure. I will coordinate the public
disclosure timing with you.

## References

- https://github.com/ag2ai/ag2/security/advisories/GHSA-224h-jmfq-qc67

Page: https://cve.now/GHSA-224H-JMFQ-QC67

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
