-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Swift: Add Command Injection query (CWE-078) #13726
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
Swift: Add Command Injection query (CWE-078) #13726
Conversation
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.
Hi @maikypedia , this query looks great! You've marked it as a work-in-progress so I'll just make a few small comments for now. When you're ready we can either do a more detailed review (and add some tests) - or we can just merge your work it into an 'experimental' directory if you'd prefer us to take it from there.
swift/ql/lib/codeql/swift/security/CommandInjectionExtensions.qll
Outdated
Show resolved
Hide resolved
swift/ql/lib/codeql/swift/security/CommandInjectionExtensions.qll
Outdated
Show resolved
Hide resolved
@maikypedia are you still working on this? Can I help with anything? |
Co-authored-by: Geoffrey White <40627776+geoffw0@users.noreply.github.com>
Hi @geoffw0 , the query is already finished, only the tests are missing but I am not familiar with writing stubs for swift 😅 |
OK, please would you move the query from Thanks! PS: I can |
Done 😁 |
QHelp previews: swift/ql/src/experimental/Security/CWE-078/CommandInjection.qhelpSystem command built from user-controlled sourcesConstructing a system command with unsanitized user input is dangerous, since a malicious user may be able to craft input that executes arbitrary code. RecommendationIf possible, use hard-coded string literals to specify the command to run. Instead of interpreting user input directly as command names, examine the input and then choose among hard-coded string literals. If this is not possible, then add sanitization code to verify that the user input is safe before using it. ExampleThe following examples execute code from user input without sanitizing it first:
If user input is used to construct a command it should be checked first. This ensures that the user cannot insert characters that have special meanings.
References
|
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.
Thank you again for this contribution!
WIP