{"id":"GHSA-m64x-33q8-m5h7","kind":"vulnerability","aliases":["GHSA-m64x-33q8-m5h7"],"related":[],"title":"GitPython parse_actor_and_date() is vulnerable to quadratic backtracking on malformed identity lines","description":"### Summary\n\nThis is a residual of GHSA-g5vv-9gxw-82hx / CVE-2026-87819. The 3.1.60 fix made `Actor._from_string` regex-free, but `parse_actor_and_date` still runs `_re_actor_epoch` on the same author/committer/tagger line one step earlier. That pattern backtracks quadratically when the trailing epoch or timezone is missing or malformed, so the same class of slow parse is still reachable in 3.1.62.\n\n### Details\n\n`git/objects/util.py:322`:\n\n```python\n_re_actor_epoch = re.compile(r\"^.+? (.*) (\\d+) ([+-]\\d+).*$\")\n```\n\n`.+?` and `(.*)` can both absorb the same run of spaces, and the required ` (\\d+) ([+-]\\d+)` tail is only checked after them. On a long line with no valid tail, the search retries every split point.\n\nIt is called from `parse_actor_and_date` (`git/objects/util.py:335`), which runs on the author and committer lines in `Commit._deserialize` (`git/objects/commit.py:917`, `:931`) and on the tagger line in `git/objects/tag.py:129`.\n\nThe published payload (letters plus an unterminated `<`) is fast on 3.1.62. Replacing the letters with spaces is not:\n\n| author line (after `author `) | 2 KB | 8 KB | 32 KB |\n|---|---|---|---|\n| `'a'*n + ' <'` (advisory payload) | 0.0 ms | 0.1 ms | 0.4 ms |\n| `' '*n` | 28 ms | 453 ms | 7,700 ms |\n| valid line, long name (control) | 0.0 ms | 0.0 ms | 0.0 ms |\n\nCost grows about 16x for each 4x increase in length.\n\n### PoC\n\n```python\nimport time\nfrom git.objects.util import parse_actor_and_date\n\nline = \"author \" + \" \" * 32000\nt = time.perf_counter()\nparse_actor_and_date(line)\nprint(f\"{time.perf_counter() - t:.1f} s\")   # ~7 s on 3.1.62\n```\n\nEnd to end, reading `Commit.author` on a commit object whose author line is 32 KB of spaces followed by any malformed tail (no epoch, no timezone, non-numeric epoch, or bad timezone) takes about 7.2 s per access. The same line with a valid `1191999972 -0700` tail takes 1.3 ms.\n\nNote for reproducing: `git hash-object -t commit -w` refuses such an object (`missingEmail`), so the test object was written with `--literally`. A remote can still serve one, because `fetch.fsckObjects` and `transfer.fsckObjects` default to false. This is the same delivery model as CVE-2026-87819 (\"craft a commit object with a malformed author field\").\n\n### Impact\n\nCPU exhaustion (CWE-1333) in any application that uses GitPython to read commits or tags from an untrusted repository: CI tooling, repository scanners, code-hosting integrations. Each access to `Commit.author`, `Commit.committer` or `TagObject.tagger` on a crafted object costs seconds, and a repository can contain many such objects.\n\n### Suggested fix\n\nMatch the leading field name with `.[^ ]*` instead of `.+?`. Both stop at the first space after the first character, but `.[^ ]*` cannot overlap the following `(.*)`, so the backtracking disappears:\n\n```python\n_re_actor_epoch = re.compile(r\"^.[^ ]* (.*) (\\d+) ([+-]\\d+).*$\")\n_re_only_actor = re.compile(r\"^.[^ ]* (.*)$\")\n```\n\nVerification on current main (73a72c9):\n\n- Differential over 368 actor lines (real-world shapes plus edge cases): 0 differences in match groups for either regex.\n- `' '*n` at 64 KB: 32,170 ms before, 0.98 ms after. Valid lines are unchanged (0.01 ms).\n- The existing test suite gives the same pass/fail set with and without the change\n- The new regression test, `test_parse_actor_and_date_malformed_line_is_linear`, fails on the old pattern (8.4 s) and passes with the fix (0.5 s).\n\nThe full patch (fix plus regression test) is attached below.\n\n```diff\ndiff --git a/git/objects/util.py b/git/objects/util.py\nindex a68d701f..d8c0594d 100644\n--- a/git/objects/util.py\n+++ b/git/objects/util.py\n@@ -319,8 +319,11 @@ def parse_date(string_date: Union[str, datetime]) -> Tuple[int, int]:\n \n \n # Precompiled regexes\n-_re_actor_epoch = re.compile(r\"^.+? (.*) (\\d+) ([+-]\\d+).*$\")\n-_re_only_actor = re.compile(r\"^.+? (.*)$\")\n+# The leading field name (\"author\", \"committer\", \"tagger\") is matched with ``.[^ ]*`` rather than\n+# ``.+?``: both stop at the first space after the first character, but ``.[^ ]*`` cannot overlap the\n+# following ``(.*)``, so a line with no valid trailing epoch/offset no longer backtracks quadratically.\n+_re_actor_epoch = re.compile(r\"^.[^ ]* (.*) (\\d+) ([+-]\\d+).*$\")\n+_re_only_actor = re.compile(r\"^.[^ ]* (.*)$\")\n \n \n def parse_actor_and_date(line: str) -> Tuple[Actor, int, int]:\ndiff --git a/test/test_util.py b/test/test_util.py\nindex cf4299d5..e1631420 100644\n--- a/test/test_util.py\n+++ b/test/test_util.py\n@@ -22,6 +22,7 @@ from git.cmd import dashify\n from git.objects.util import (\n     altz_to_utctz_str,\n     from_timestamp,\n+    parse_actor_and_date,\n     parse_date,\n     tzoffset,\n     utctz_to_altz,\n@@ -571,6 +572,30 @@ class TestUtils(TestBase):\n             Actor(\"name last another\", \"some-very-long-email@example.com\"),\n         )\n \n+    def test_parse_actor_and_date_malformed_line_is_linear(self):\n+        # A long author line whose trailing epoch/offset is missing or malformed used to make\n+        # _re_actor_epoch backtrack quadratically: ~7 s per Commit.author access for a 32 KB line.\n+        # The parse result must be unchanged; only the time spent reaching it should move.\n+        for tail in (\"\", \" notanumber -0700\", \" 1191999972\", \" -0700\", \" 1191999972 xx\"):\n+            line = \"author \" + \" \" * 32000 + tail\n+            start = time.perf_counter()\n+            actor, epoch, offset = parse_actor_and_date(line)\n+            self.assertLess(time.perf_counter() - start, 1.0)\n+            self.assertEqual(epoch, 0)\n+            self.assertEqual(offset, 0)\n+\n+        # Well-formed lines, including one with a long name, still parse exactly as before.\n+        actor, epoch, offset = parse_actor_and_date(\n+            \"author Tom Preston-Werner <tom@mojombo.com> 1191999972 -0700\"\n+        )\n+        self.assertEqual(actor, Actor(\"Tom Preston-Werner\", \"tom@mojombo.com\"))\n+        self.assertEqual(epoch, 1191999972)\n+        self.assertEqual(offset, 25200)\n+\n+        actor, epoch, offset = parse_actor_and_date(\"author \" + \"a \" * 16000 + \"<a@b> 1 -0700\")\n+        self.assertEqual(actor.email, \"a@b\")\n+        self.assertEqual(epoch, 1)\n+\n     @ddt.data(\n         (\"name\", \"\"),\n         (\"name\", \"prefix_\"),\n```\n\nFound with AI assistance (Claude) and verified by hand.\n\nBrian Willows","summary":"GitPython's parse_actor_and_date() uses a regex that backtracks quadratically on author, committer or tagger lines with a missing or malformed epoch and timezone. Reading Commit.author, Commit.committer or TagObject.tagger on a crafted object from an untrusted repository burns CPU for seconds per access.","severity":"high","cvss":null,"epss":null,"exploited":false,"exploited_at":null,"products":[{"name":"GitPython","fixed":["3.2.0"],"affected":"<= 3.1.62","ecosystem":"pypi"}],"ecosystems":["pypi"],"tags":["ci","cwe-1333","gitpython","package","python","repository-scanners"],"not_affected_if":["local-trusted-repos-only","no-commit-metadata-reads"],"how_to_check":"- Run `pip show GitPython` and confirm the installed version is above `3.2.0` or otherwise not `3.1.62` or older.\n- Find the GitPython pin in requirements or lockfiles and check it against `3.2.0`.","fix":"- Upgrade GitPython to `3.2.0` or later.\n- Until upgraded, avoid reading commit or tag metadata from untrusted repositories.","status":"open","published_at":"2026-10-27T15:26:24+00:00","first_seen_at":"2026-10-27T15:28:57+00:00","triaged_at":"2026-10-27T15:29:28+00:00","updated_at":"2026-10-27T15:29:28+00:00","category":"package","confidence":0.8,"triage":{"at":"2026-10-27T15:29:28Z","model":"claude-haiku-5-5","output":{"fix":"- Upgrade GitPython to `3.2.0` or later.\n- Until upgraded, avoid reading commit or tag metadata from untrusted repositories.","reach":"internet","title":"GitPython: crafted commit author line stalls parsing for seconds","impact":"low","summary":"GitPython's parse_actor_and_date() uses a regex that backtracks quadratically on author, committer or tagger lines with a missing or malformed epoch and timezone. Reading Commit.author, Commit.committer or TagObject.tagger on a crafted object from an untrusted repository burns CPU for seconds per access.","category":"package","nicknames":[],"who_cares":["python","gitpython","ci","repository-scanners"],"confidence":0.8,"needs_auth":"no","worst_case":"CPU exhaustion stalls the application for seconds per access","analyst_note":"","how_to_check":"- Run `pip show GitPython` and confirm the installed version is above `3.2.0` or otherwise not `3.1.62` or older.\n- Find the GitPython pin in requirements or lockfiles and check it against `3.2.0`.","needs_analyst":false,"not_affected_if":["local-trusted-repos-only","no-commit-metadata-reads"],"who_is_affected":"Applications that use GitPython to read commits or tags from repositories they do not control, such as CI tooling, repository scanners and code-hosting integrations. Code that only works on repositories the team owns, or never reads author and tagger fields, is far less exposed.","user_interaction":"no","needs_special_setup":"no","severity_if_unknown":"high"},"cost_usd":0.000875,"input_tokens":5982,"output_tokens":554,"severity_before":"high"},"analyst_status":null,"analyst_note":null,"search":"'+319':625C '-0700':368C '-1333':28B,432C '-2026':92C,417C '-319':623C '-87819':93C,418C '0':536C '0.0':254C,273C,275C,277C '0.01':559C '0.1':256C '0.4':258C '0.5':600C '0.98':552C '1.3':371C '100644':620C '11':626C '1191999972':367C '129':221C '16x':282C '170':549C '1f':316C '2':244C '28':261C '3.1.60':95C '3.1.62':145C,232C,321C '32':248C,335C,548C '32000':302C '322':148C '335':200C '33q8':18A,23A '368':526C '453':263C '4x':285C '64':546C '7':265C,318C '7.2':357C '700':266C '73a72c9':523C '8':246C,624C '8.4':593C '82hx':90C '917':212C '931':213C '9gxw':89C 'a/git/objects/util.py':615C,621C 'a68d701f':618C 'absorb':160C 'access':79B,360C,457C 'actor':3A,38B,104C,110C,151C,196C,297C,307C,508C,516C,527C,581C,641C,649C 'actor._from_string':98C 'advisori':252C 'applic':435C 'attach':610C 'author':48B,205C,240C,243C,301C,332C,426C,656C 'author/committer/tagger':115C 'b/git/objects/util.py':616C,622C 'backtrack':10A,45B,122C,504C 'bad':353C 'burn':74B 'c':673C 'call':193C 'cannot':498C 'case':535C 'chang':574C 'charact':496C 'check':174C 'ci':26B,448C 'class':137C 'code':453C 'code-host':452C 'commit':329C,381C,421C,441C 'commit._deserialize':210C 'commit.author':62B,326C,459C 'commit.committer':63B,460C 'committ':49B,207C,657C 'contain':473C 'control':272C 'cost':279C,467C 'counter':305C,314C 'cpu':75B,429C 'craft':68B,419C,465C 'current':521C 'cve':91C,416C 'cwe':27B,431C 'd':155C,156C,169C,170C,512C,513C,645C,646C 'd8c0594d':619C 'date':5A,40B,106C,198C,299C,309C,583C,629C,631C 'datetim':634C 'def':627C 'default':406C 'deliveri':413C 'detail':146C 'diff':612C,613C 'differ':537C 'differenti':524C 'disappear':505C 'earlier':119C 'edg':534C 'either':542C 'end':322C,324C 'epoch':58B,111C,127C,152C,345C,351C,509C,642C 'everi':188C 'exhaust':430C 'exist':562C 'f':312C 'fail':588C 'fals':408C 'fast':230C 'fetch.fsckobjects':403C 'field':427C,482C,654C 'first':491C,495C,668C,672C 'fix':96C,478C,599C,605C 'follow':339C,501C 'free':101C 'full':603C 'g5vv':88C 'ghsa':16A,21A,87C 'ghsa-g5vv-9gxw-82hx':86C 'ghsa-m64x-33q8-m5h7':15A,20A 'git':376C,614C 'git.objects.util':294C 'git/objects/commit.py':211C 'git/objects/tag.py':220C 'git/objects/util.py':147C,199C 'gitpython':1A,25A,29B,35B,438C 'give':565C 'group':540C 'grow':280C 'hash':378C 'hash-object':377C 'host':454C 'ident':13A 'impact':428C 'import':291C,295C 'increas':286C 'index':617C 'instead':485C 'int':636C,637C 'integr':455C 'kb':245C,247C,249C,336C,547C 'lead':481C,653C 'length':288C 'letter':225C,235C 'line':14A,52B,116C,180C,208C,218C,241C,269C,300C,310C,333C,363C,528C,556C,585C 'linear':587C 'liter':395C 'long':179C,270C 'm5h7':19A,24A 'm64x':17A,22A 'made':97C 'main':522C 'malform':12A,57B,133C,342C,425C,584C 'mani':474C 'match':479C,539C,660C 'miss':55B,131C 'missingemail':387C 'model':414C 'ms':255C,257C,259C,262C,264C,267C,274C,276C,278C,372C,550C,553C,560C 'n':251C,260C,544C 'name':271C,483C,655C 'new':576C 'non':349C 'non-numer':348C 'note':373C 'numer':350C 'object':69B,330C,379C,386C,391C,422C,466C,476C 'old':591C 'one':117C,401C 'overlap':499C 'packag':30B 'pars':2A,37B,103C,140C,195C,296C,306C,580C,628C 'pass':596C 'pass/fail':568C 'patch':604C 'pattern':121C,592C 'payload':224C,253C 'per':78B,359C 'plus':226C,533C,606C 'poc':289C 'point':190C 'precompil':638C 'print':311C 'publish':223C 'python':31B,149C,290C,506C 'quadrat':9A,46B,123C 'r':154C,511C,518C,644C,651C 'rather':662C 're':109C,150C,507C,514C,640C,647C 're.compile':153C,510C,517C,643C,650C 'reachabl':143C 'read':61B,325C,440C 'real':530C 'real-world':529C 'refus':383C 'regex':43B,100C,543C,639C 'regex-fre':99C 'regress':577C,607C 'remot':397C 'replac':233C 'repositori':33B,73B,447C,450C,471C 'repository-scann':32B 'reproduc':375C 'requir':168C 'residu':84C 'retri':187C 'run':108C,163C,202C 'scanner':34B,451C 'search':186C 'second':77B,468C 'serv':400C 'set':569C 'shape':532C 'slow':139C 'space':165C,237C,338C,492C,669C 'split':189C 'step':118C 'still':107C,142C,399C 'stop':488C,665C 'str':633C 'string':630C 'suggest':477C 'suit':564C 'summari':80C 'tag':443C 'tagger':51B,217C,658C 'tagobject.tagger':65B,462C 'tail':171C,184C,343C,369C 'take':355C,370C 'test':390C,563C,578C,579C,608C 'time':292C 'time.perf':304C,313C 'timezon':60B,129C,347C,354C 'tool':449C 'trail':126C 'transfer.fsckobjects':405C 'tupl':635C 'unchang':558C 'union':632C 'untermin':228C 'untrust':72B,446C 'use':41B,437C 'valid':183C,268C,366C,555C 'verif':519C 'vulner':7A 'w':382C 'whose':331C 'without':572C 'world':531C 'written':393C","nicknames":[],"mitigations":[],"who_affected":"Applications that use GitPython to read commits or tags from repositories they do not control, such as CI tooling, repository scanners and code-hosting integrations. Code that only works on repositories the team owns, or never reads author and tagger fields, is far less exposed.","tier":"B","verified":{},"analyst_revisit_at":null,"first_public_at":"2026-10-27T15:26:24+00:00","kev":null,"cvss_vector":null,"cvss_by":null,"poc_count":0,"sources":[{"source":"ghsa","external_id":"GHSA-m64x-33q8-m5h7","url":"https://github.com/advisories/GHSA-m64x-33q8-m5h7","severity":"high","published_at":"2026-10-27T15:26:24+00:00","modified_at":"2026-10-27T15:26:25+00:00","first_seen_at":"2026-10-27T15:28:57+00:00","fetched_at":"2026-10-27T15:28:57+00:00","note":null}],"documents":[],"notice":"Free to read at a human pace. An API with keys and an MCP server are in preparation; early access: hello@infrastack.ai"}