Related: Modern Cryptography for encryption practices, Writing Ruby with TypeProf for type safety, A side gig for RuboCop, the Bookworm code crawler for security scanning
Agenda
- Ethitcally hacking github
- protecting ourselv
- keeping secrets
Github App Structure
- Huge monolith
- Built on rails
- MVC
- Views utilize viewComponent framework
- Build component-driven UI
- render ruby object into markup
What is send()
- method to do dynamic method dispatch
obj = HelloWorld.new
obj.send("print", "world)Thinking like hacker
obj.send('send', 'send', 'send')- identify potential vulnerability
- determine exploitability
- any safeguards persent
- are sagefuards bypassable
- any explotation
- Zero argument
- Call Zero-arguments with arity of 0 or -1
- Drop into rails console via console
- Tried invoking all methods and collected response for analysis identified that disclosed 1k+ variables
- _gh_render cookie
- Use marshal ENTERPRISE_SESSION_SECRET
- Encrypt marshalled paylout
__dir__(), caller()
class()
__calleee__(), __method__(), methods()Protecting Ourselves
Vulnerablity lifecylcle
- Intake
- Bug bounty program
- code scanning allerts
- red team / engineering team
- customer report
- Triage
- set priotity
- anaylze the report
- repspond
- Remediation
- Containment / eradication
- Mitigation / remediation
- Variant Analysis
- Taking this as starting point
- expanding and try to lalala
- Disclosure
- Disclose the incident publicly
- issuing CVE
- releasing new patches
- send email
Code Scanning Tools
- Brakeman (Rails)
- Run any stage in development
- Rubocop
- PublicSendCop
- Semgrep / Opengrep
- CoeQL
- updated the default query set
Takeways
- Use powefrul languaage feature with greate care
- utilize and customize your code scanning tools
- always validate user controlled inputs in you r code
def identifier_for(repostiory)
repository.send(@repository_identifier_key)
end
# After
when :id, "id"
repository.id
else
repository.global_relay_id
endBlameless culture No pointing
I want to use send safely
send() # Public
public_send(:secert)Variable Method
Variable TargetDo the remediation
def rid_key
case when
else
nil
endFully Compromised
Keeping Sicerts
Challenges of rotating secrets
- Separeate config and secrets
- identfiying owning teams and impact of rotation
- automating secrrets rotation
- how long things will take
- have a playbook / rotation plan and actually test it
Storage Mechanism
- Env
- rails credentials
- networked secrets store ⇐- best(hashicorp, azure key vault, etc)
- Audability
- hashicorp vault
- jit accesss
- least privillege
- secrets versioning
Goal achieve a minimal footprint for sensitive data in memory
- Overloading methods
- moving away from ENV
- using subprocess
- external store
- custom class for managing secrets