{"record":{"id":"40a6246887959d8e","repo":"modelcontextprotocol/servers","slug":"invalid-start-timestamp-start-timestamp-can","errorCode":null,"errorMessage":"Invalid start_timestamp: '{start_timestamp}' - cannot start with '-'","messagePattern":"Invalid start_timestamp: '(.+?)' - cannot start with '-'","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/git/src/mcp_server_git/server.py","lineNumber":163,"sourceCode":"            try:\n                resolved.relative_to(repo_root)\n            except ValueError:\n                raise ValueError(\n                    f\"Path '{f}' is outside the repository '{repo_root}'\"\n                )\n        # Use '--' to prevent files starting with '-' from being interpreted as options\n        repo.git.add(\"--\", *files)\n    return \"Files staged successfully\"\n\ndef git_reset(repo: git.Repo) -> str:\n    repo.index.reset()\n    return \"All staged changes reset\"\n\ndef git_log(repo: git.Repo, max_count: int = 10, start_timestamp: Optional[str] = None, end_timestamp: Optional[str] = None) -> list[str]:\n    if start_timestamp or end_timestamp:\n        # Defense in depth: reject timestamps starting with '-' to prevent flag injection\n        if start_timestamp and start_timestamp.startswith(\"-\"):\n            raise ValueError(f\"Invalid start_timestamp: '{start_timestamp}' - cannot start with '-'\")\n        if end_timestamp and end_timestamp.startswith(\"-\"):\n            raise ValueError(f\"Invalid end_timestamp: '{end_timestamp}' - cannot start with '-'\")\n        # Use git log command with date filtering\n        args = []\n        if start_timestamp:\n            args.extend(['--since', start_timestamp])\n        if end_timestamp:\n            args.extend(['--until', end_timestamp])\n        args.extend(['--format=%H%n%an%n%ad%n%s%n'])\n\n        log_output = repo.git.log(*args).split('\\n')\n\n        log = []\n        # Process commits in groups of 4 (hash, author, date, message)\n        for i in range(0, len(log_output), 4):\n            if i + 3 < len(log_output) and len(log) < max_count:\n                log.append(\n                    f\"Commit: {log_output[i]}\\n\"","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/modelcontextprotocol/servers/blob/76d64c822f5125032f89eb71dbdb94e42b434821/src/git/src/mcp_server_git/server.py#L145-L181","documentation":"git_log() rejects a start_timestamp that starts with '-' to prevent flag injection into `git log --since <value>`. The guard runs before assembling the args list. Raises ValueError (propagates raw to the MCP client). Valid timestamps are git date strings that do not begin with '-'.","triggerScenarios":"Passing start_timestamp beginning with '-'; malicious or malformed timestamp input.","commonSituations":"Adversarial input; UI letting users pass arbitrary date strings that collide with git options.","solutions":["Pass a timestamp that does not start with '-', e.g. '2024-01-01' or a relative like '2 weeks ago'.","Reject leading '-' before calling."],"exampleFix":"# before\ngit_log(repo, start_timestamp='-sMalicious')  # -> ValueError\n\n# after\nts = start_timestamp or ''\nif ts.startswith('-'):\n    raise ValueError('start_timestamp must not start with -')\ngit_log(repo, start_timestamp=ts or None)","handlingStrategy":"validation","validationCode":"def safe_timestamp(ts: str | None) -> str | None:\n    if ts is not None and ts.startswith('-'):\n        raise ValueError('start_timestamp must not start with -')\n    return ts","typeGuard":null,"tryCatchPattern":"try:\n    git_log(repo, start_timestamp=ts)\nexcept ValueError as e:\n    if 'cannot start with' in e.args[0]:\n        # normalize/strip the offending timestamp\n    raise","preventionTips":["Reject timestamps beginning with '-' before passing to git_log.","Use canonical date formats (ISO 8601) or git relative forms like '2 weeks ago'."],"tags":["git","python","security","flag-injection","validation"],"backgroundTag":null,"analyzedSha":"76d64c822f5125032f89eb71dbdb94e42b434821","analyzedAt":"2026-08-12T10:02:41.718Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}