Swift: Add Command Injection query (CWE-078)#13726
Conversation
geoffw0
left a comment
There was a problem hiding this comment.
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
|
geoffw0
left a comment
There was a problem hiding this comment.
Thank you again for this contribution!
WIP