-
Notifications
You must be signed in to change notification settings - Fork 1
[EnforceAuth] Add policy: EA Financial Global SSO #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,14 @@ | ||||||||||||||||||
| # METADATA | ||||||||||||||||||
| # title: EA Financial Global SSO | ||||||||||||||||||
| # description: Global unified access policy for all systems across the global entities of EA Financial | ||||||||||||||||||
| package ea_financial_global_sso | ||||||||||||||||||
|
|
||||||||||||||||||
| import rego.v1 | ||||||||||||||||||
|
|
||||||||||||||||||
| default allow = false | ||||||||||||||||||
|
|
||||||||||||||||||
| # Allow Rule | ||||||||||||||||||
| allow if { | ||||||||||||||||||
| input.subject.id contains "EAID" | ||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Verify Rego contains() usage patterns and input id field references in policies (read-only).
rg -n --type-add 'rego:*.rego' --type rego -C2 '\bcontains\s*\(' infra/opa/policies
rg -n --type-add 'rego:*.rego' --type rego -C2 '\binput\.(subject|user)\.id\b' infra/opa/policiesRepository: EnforceAuth/ea-financial Length of output: 10575 🏁 Script executed: # Find references to ea_financial_global_sso policy
rg -n 'ea_financial_global_sso' --type-list | head -5
fd . -name '*sso*' -o -name '*ea_financial*'
find . -type f -name '*.ts' -o -name '*.js' | xargs grep -l 'ea_financial_global_sso' 2>/dev/null | head -5Repository: EnforceAuth/ea-financial Length of output: 688 🏁 Script executed: # Search for OPA input structure and where this policy is evaluated
rg -n 'subject.*id|user.*id' projects/consumer-accounts-internal-api/src/services/opaService.ts -A2 -B2Repository: EnforceAuth/ea-financial Length of output: 431 🏁 Script executed: # Look at the full content of ea_financial_global_sso.rego to understand context
cat infra/opa/policies/ea_financial_global_sso.regoRepository: EnforceAuth/ea-financial Length of output: 350 Fix invalid Rego syntax and correct input field path. Line 12 has two critical issues: (1) Fix allow if {
- input.subject.id contains "EAID"
+ contains(input.user.id, "EAID")
}📝 Committable suggestion
Suggested change
🧰 Tools🪛 GitHub Actions: Path-based Testing[error] 12-12: opa fmt --diff policies failed. rego_parse_error: unexpected contains keyword: expected \n or ; or } at line 12 (input.subject.id contains "EAID"). 🤖 Prompt for AI Agents |
||||||||||||||||||
| } | ||||||||||||||||||
|
Comment on lines
+11
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the correct input shape ( The request producer builds 💡 Proposed fix allow if {
- contains(input.subject.id, "EAID")
+ is_string(input.user.id)
+ contains(input.user.id, "EAID")
}🧰 Tools🪛 GitHub Actions: Path-based Testing[error] 12-12: opa fmt --diff policies failed. rego_parse_error: unexpected contains keyword: expected \n or ; or } at line 12 (input.subject.id contains "EAID"). 🤖 Prompt for AI AgentsAvoid substring-based identity checks for auth decisions.
💡 Proposed hardening allow if {
- contains(input.user.id, "EAID")
+ is_string(input.user.id)
+ startswith(input.user.id, "EAID")
+ input.user.isActive == true
}📝 Committable suggestion
Suggested change
🧰 Tools🪛 GitHub Actions: Path-based Testing[error] 12-12: opa fmt --diff policies failed. rego_parse_error: unexpected contains keyword: expected \n or ; or } at line 12 (input.subject.id contains "EAID"). 🤖 Prompt for AI Agents |
||||||||||||||||||
|
|
||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛑 Security Vulnerability: The
containsoperator performs substring matching, allowing any user with "EAID" anywhere in their ID to gain access. For example, IDs like "FAKE_EAID_HACKER", "my_eaid_test", or "compromised_EAID" would all incorrectly grant access. Usestartswithto ensure only IDs beginning with "EAID" are authorized.1Footnotes
CWE-185: Incorrect Regular Expression - https://cwe.mitre.org/data/definitions/185.html ↩