Skip to content
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

Add security rules for empty passwords in Ruby and Rust applications #109

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
131 changes: 131 additions & 0 deletions rules/ruby/security/ruby-cassandra-empty-password-ruby.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
id: ruby-cassandra-empty-password-ruby
language: ruby
severity: warning
ESS-ENN marked this conversation as resolved.
Show resolved Hide resolved
message: >-
The application creates a database connection with an empty password.
This can lead to unauthorized access by either an internal or external
malicious actor. To prevent this vulnerability, enforce authentication
when connecting to a database by using environment variables to securely
provide credentials or retrieving them from a secure vault or HSM
(Hardware Security Module).
note: >-
[CWE-287] Improper Authentication.
[REFERENCES]
- https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html
utils:
Cassandra.cluster():
# Cassandra.cluster(..., password: "", ...)
kind: call
all:
- has:
stopBy: neighbor
kind: constant
regex: ^Cassandra$
- has:
stopBy: neighbor
regex: ^.$
- has:
stopBy: neighbor
kind: identifier
regex: ^cluster$
- has:
stopBy: neighbor
kind: argument_list
has:
stopBy: end
kind: pair
all:
- has:
stopBy: neighbor
kind: hash_key_symbol
regex: ^password$
- has:
stopBy: neighbor
kind: string
not:
has:
stopBy: neighbor
kind: string_content
- inside:
stopBy: end
kind: program
has:
stopBy: end
kind: call
pattern: require 'cassandra'
Cassandra.cluster()_with_instance:
# Cassandra.cluster(..., password: "", ...)
kind: call
all:
- has:
stopBy: neighbor
kind: constant
regex: ^Cassandra$
- has:
stopBy: neighbor
regex: ^.$
- has:
stopBy: neighbor
kind: identifier
regex: ^cluster$
- has:
stopBy: neighbor
kind: argument_list
has:
stopBy: end
kind: pair
all:
- has:
stopBy: neighbor
kind: hash_key_symbol
regex: ^password$
- has:
stopBy: neighbor
kind: identifier
pattern: $SECRET
- inside:
stopBy: end
kind: program
has:
stopBy: end
kind: call
pattern: require 'cassandra'
- any:
- follows:
stopBy: end
kind: assignment
all:
- has:
stopBy: neighbor
kind: identifier
pattern: $SECRET
- has:
stopBy: neighbor
kind: string
not:
has:
stopBy: neighbor
kind: string_content
- inside:
stopBy: end
kind: assignment
follows:
stopBy: end
kind: assignment
all:
- has:
stopBy: neighbor
kind: identifier
pattern: $SECRET
- has:
stopBy: neighbor
kind: string
not:
has:
stopBy: neighbor
kind: string_content
ESS-ENN marked this conversation as resolved.
Show resolved Hide resolved
rule:
kind: call
any:
- matches: Cassandra.cluster()
- matches: Cassandra.cluster()_with_instance
Loading