{"id":34801071,"url":"https://github.com/feliceiorillo/jwt-analyzer","last_synced_at":"2026-01-13T20:51:51.746Z","repository":{"id":330416169,"uuid":"1122234054","full_name":"feliceiorillo/jwt-analyzer","owner":"feliceiorillo","description":"A .NET CLI tool that performs static analysis on C# source code to detect insecure or misconfigured JWT authentication patterns.","archived":false,"fork":false,"pushed_at":"2025-12-25T09:26:15.000Z","size":46,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"trunk","last_synced_at":"2025-12-26T22:29:58.362Z","etag":null,"topics":["authentication","authorization","ci-cd","csharp","devsecops","dotnet","dotnet-cli","jwt","jwt-security","security","security-tool","static-analysis","token-security"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/feliceiorillo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-24T10:26:05.000Z","updated_at":"2025-12-26T15:12:33.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/feliceiorillo/jwt-analyzer","commit_stats":null,"previous_names":["feliceiorillo/jwt-analyzer"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/feliceiorillo/jwt-analyzer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/feliceiorillo%2Fjwt-analyzer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/feliceiorillo%2Fjwt-analyzer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/feliceiorillo%2Fjwt-analyzer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/feliceiorillo%2Fjwt-analyzer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/feliceiorillo","download_url":"https://codeload.github.com/feliceiorillo/jwt-analyzer/tar.gz/refs/heads/trunk","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/feliceiorillo%2Fjwt-analyzer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28400124,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T14:36:09.778Z","status":"ssl_error","status_checked_at":"2026-01-13T14:35:19.697Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["authentication","authorization","ci-cd","csharp","devsecops","dotnet","dotnet-cli","jwt","jwt-security","security","security-tool","static-analysis","token-security"],"created_at":"2025-12-25T11:38:41.847Z","updated_at":"2026-01-13T20:51:51.741Z","avatar_url":"https://github.com/feliceiorillo.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JWT Analyzer\n\nA .NET 10 CLI tool that performs static analysis on C# source code to detect insecure or misconfigured JWT authentication.\n\n## Features\n\n- **Dual Analysis Modes**: Roslyn-based semantic analysis + regex pattern matching\n- **Recursive Scanning**: Scans all `.cs` files in a directory, excluding `bin/`, `obj/`, `.git/`, etc.\n- **Semantic Analysis**: Uses Microsoft.CodeAnalysis for accurate detection of JWT misconfigurations\n- **Regex Fallback**: Lightweight pattern matching for quick scans\n- **Multiple Output Formats**: Console, Markdown, and JSON reporting\n- **Security Scoring**: 0-100 score based on findings severity\n- **CI/CD Integration**: Configurable exit codes for build pipelines\n\n## Installation\n\nBuild the project:\n\n```bash\ndotnet build -c Release\n```\n\n## Usage\n\n```bash\njwt-analyzer \u003cpath\u003e [options]\n```\n\n### Arguments\n\n- `\u003cpath\u003e` - Path to scan for C# source files\n\n### Options\n\n- `--format \u003cformat\u003e` - Output format: `console`, `md`, `json` (default: `console`)\n- `--fail-on \u003clevel\u003e` - Exit with code 1 if findings \u003e= level: `none`, `medium`, `high`, `critical` (default: `none`)\n- `--output \u003cfile\u003e` - Write report to file instead of console\n- `--mode \u003cmode\u003e` - Analysis mode: `regex`, `semantic`, `hybrid` (default: `hybrid`)\n\n### Analysis Modes\n\n- **`regex`** - Fast regex-based pattern matching (legacy mode)\n- **`semantic`** - Roslyn-based semantic analysis (accurate, slower)\n- **`hybrid`** - Both semantic and regex analysis (recommended)\n\n### Examples\n\nScan current directory with semantic analysis:\n```bash\njwt-analyzer . --mode semantic\n```\n\nGenerate markdown report with hybrid analysis:\n```bash\njwt-analyzer ./src --format md --output report.md --mode hybrid\n```\n\nFail build on high severity issues (regex only for speed):\n```bash\njwt-analyzer ./src --fail-on high --mode regex\n```\n\nGenerate JSON report for CI with full semantic analysis:\n```bash\njwt-analyzer ./src --format json --output results.json --fail-on medium --mode semantic\n```\n\n## Detection Rules\n\n### CRITICAL Severity (-25 points each)\n\n| Rule ID | Description | Semantic | Regex |\n|---------|-------------|----------|-------|\n| JWT001 | `ValidateIssuer = false` - Accepts tokens from any issuer | ? | ? |\n| JWT002 | `ValidateAudience = false` - Accepts tokens for any audience | ? | ? |\n| JWT003 | `SecurityAlgorithms.None` - Allows unsigned tokens | | ? |\n| JWT004 | `alg = \"none\"` - Creates unsigned tokens | | ? |\n\n### HIGH Severity (-10 points each)\n\n| Rule ID | Description | Semantic | Regex |\n|---------|-------------|----------|-------|\n| JWT005 | `RequireExpirationTime = false` - Accepts tokens without expiration | ? | ? |\n| JWT006 | `ValidateLifetime = false` - Accepts expired tokens | ? | ? |\n| JWT007 | `ClockSkew \u003e 5 minutes` - Excessive time tolerance | ? | ? |\n| JWT008 | Hardcoded symmetric signing key in source code | ? | ? |\n\n### MEDIUM Severity (-5 points each)\n\n| Rule ID | Description | Semantic | Regex |\n|---------|-------------|----------|-------|\n| JWT009 | Hardcoded `ValidIssuer` value | | ? |\n| JWT010 | Hardcoded `ValidAudience` value | | ? |\n| JWT011 | Manual JWT parsing without validation | | ? |\n\n## Semantic Analysis\n\nThe semantic analyzer uses Microsoft.CodeAnalysis (Roslyn) to:\n\n- **Parse syntax trees** for accurate code structure analysis\n- **Build semantic models** to understand type information\n- **Detect JWT configurations** in `TokenValidationParameters` and `JwtBearerOptions`\n- **Avoid false positives** by understanding code context\n- **Analyze initialization patterns** including object initializers and property assignments\n\n### Benefits over Regex\n\n- More accurate detection of configuration issues\n- Understands C# syntax and semantics\n- Fewer false positives\n- Can detect issues across method boundaries\n- Type-aware analysis\n\n## Security Score\n\nThe security score starts at 100 and decreases based on findings:\n- **CRITICAL**: -25 points\n- **HIGH**: -10 points\n- **MEDIUM**: -5 points\n\nScore is clamped between 0-100.\n\n## Exit Codes\n\n- `0` - Success (or findings below `--fail-on` threshold)\n- `1` - Failure (findings \u003e= `--fail-on` threshold, or error)\n\n## Architecture\n\n```\njwt-analyzer/\n??? CLI/              # Command-line parsing\n??? Scanning/         # Source file discovery\n??? Rules/            # Regex-based JWT security rules\n??? Semantic/         # Roslyn-based semantic analysis\n?   ??? SemanticAnalyzer.cs\n?   ??? SemanticRuleEngine.cs\n?   ??? Rules/        # Semantic JWT security rules\n??? Engine/           # Rule execution engine\n??? Reporting/        # Output formatters\n??? Models/           # Core data structures\n```\n\n## Example Output\n\n### Console Format\n\n```\nRunning semantic analysis...\nRunning regex analysis...\n??????????????????????????????????????????????????????????????????????\n?           JWT Security Analysis Report                             ?\n??????????????????????????????????????????????????????????????????????\n\nFiles Scanned: 15\nTotal Findings: 3\n\n[CRITICAL] 1 finding(s)\n[HIGH] 1 finding(s)\n[MEDIUM] 1 finding(s)\n\nSecurity Score: 60/100\n\n????????????????????????????????????????????????????????????????????\nFindings:\n????????????????????????????????????????????????????????????????????\n\n[CRITICAL] JWT001\n  File: src/Auth/JwtConfig.cs:42\n  CRITICAL: ValidateIssuer is set to false. This allows tokens from any issuer...\n```\n\n## Performance Considerations\n\n- **Regex mode**: Fast, suitable for large codebases, may have false positives\n- **Semantic mode**: Slower, very accurate, recommended for critical analysis\n- **Hybrid mode**: Best of both worlds, deduplicates findings\n\n## Limitations\n\n- Semantic analysis requires valid C# syntax (but not full compilation)\n- Some rules only available in regex mode (e.g., JWT003, JWT004, JWT009-011)\n- No auto-fix capabilities\n- No runtime validation\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffeliceiorillo%2Fjwt-analyzer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffeliceiorillo%2Fjwt-analyzer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffeliceiorillo%2Fjwt-analyzer/lists"}