-
Notifications
You must be signed in to change notification settings - Fork 6
Revert "Removing all rules except those tested on live pipeline (#61)" #62
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
id: info-leak-on-non-formated-string | ||
language: c | ||
severity: warning | ||
message: >- | ||
Information leak on non-formatted string detected. This can lead to security | ||
vulnerabilities. Use formatted strings to prevent information leaks. | ||
note: >- | ||
[CWE-532] Insertion of Sensitive Information into Log File | ||
[OWASP A09:2021] Security Logging and Monitoring Failures | ||
[REFERENCES] | ||
- http://nebelwelt.net/files/13PPREW.pdf | ||
rule: | ||
pattern: 'printf($A);' | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
id: insecure-use-gets-function | ||
language: c | ||
message: >- | ||
Avoid 'gets()' function, it does not consider buffer boundaries and can lead | ||
to buffer overflows. Use 'fgets()' or 'gets_s()' instead. | ||
note: >- | ||
[CWE-676] Use of Potentially Dangerous Function | ||
[REFERENCES] | ||
- https://us-cert.cisa.gov/bsi/articles/knowledge/coding-practices/fgets-and-gets_s | ||
severity: warning | ||
rule: | ||
pattern: gets($$$); | ||
ESS-ENN marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
id: insecure-use-memset-function | ||
language: c | ||
message: >- | ||
Avoid 'memset()' function, it does not consider buffer boundaries and can lead | ||
to buffer overflows. Use 'memset_s()' instead. | ||
severity: warning | ||
ESS-ENN marked this conversation as resolved.
Show resolved
Hide resolved
|
||
note: >- | ||
[CWE-14]: Compiler Removal of Code to Clear Buffers | ||
[OWASP A04:2021] Insecure Design | ||
[REFERENCES] | ||
- https://cwe.mitre.org/data/definitions/14.html | ||
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/ | ||
rule: | ||
pattern: memset($$$); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
id: insecure-use-scanf-function | ||
language: c | ||
message: >- | ||
Avoid 'scanf()' function, it does not consider buffer boundaries and can lead | ||
to buffer overflows. Use 'fgets()' or 'scanf_s()' instead. | ||
severity: warning | ||
note: >- | ||
[CWE-676]: Use of Potentially Dangerous Function | ||
[REFERENCES] | ||
- http://sekrit.de/webdocs/c/beginners-guide-away-from-scanf.html | ||
rule: | ||
pattern: scanf($$$); | ||
ESS-ENN marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
id: insecure-use-strcat-function | ||
language: c | ||
message: >- | ||
Avoid 'strcat()' or 'strncat()' functions, it does not consider buffer boundaries and can lead | ||
to buffer overflows. Use 'strcat_s()' instead. | ||
severity: warning | ||
note: >- | ||
[CWE-676]: Use of Potentially Dangerous Function | ||
[REFERENCES] | ||
- https://nvd.nist.gov/vuln/detail/CVE-2019-12553 | ||
- https://techblog.mediaservice.net/2020/04/cve-2020-2851-stack-based-buffer-overflow-in-cde-libdtsvc/ | ||
rule: | ||
any: | ||
- pattern: strcat($$$); | ||
- pattern: strncat($$$); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
id: insecure-use-string-copy-function | ||
language: c | ||
severity: warning | ||
message: >- | ||
Avoid 'strcpy()' or 'strncpy()' function, it does not consider buffer boundaries and can lead | ||
to buffer overflows. Use 'strcpy_s()' instead. | ||
note: >- | ||
[CWE-676]: Use of Potentially Dangerous Function | ||
[REFERENCES] | ||
- https://cwe.mitre.org/data/definitions/676 | ||
- https://nvd.nist.gov/vuln/detail/CVE-2019-11365 | ||
rule: | ||
any: | ||
- pattern: strcpy($$$); | ||
- pattern: strncpy($$$); | ||
ESS-ENN marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
id: insecure-use-strtok-function | ||
language: c | ||
severity: warning | ||
message: >- | ||
Avoid 'strtok()' function, it is not reentrant and can lead to security | ||
vulnerabilities. Use 'strtok_r()' instead. | ||
note: >- | ||
[CWE-676]: Use of Potentially Dangerous Function | ||
[REFERENCES] | ||
- https://wiki.sei.cmu.edu/confluence/display/c/STR06-C.+Do+not+assume+that+strtok%28%29+leaves+the+parse+string+unchanged | ||
rule: | ||
pattern: strtok($$$); | ||
ESS-ENN marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
id: binary-formatter | ||
language: csharp | ||
message: 'Avoid using BinaryFormatter, it is insecure and can lead to remote code execution' | ||
severity: warning | ||
note: >- | ||
[CWE-502]: Deserialization of Untrusted Data | ||
[OWASP A08:2017]: Insecure Deserialization | ||
[OWASP A08:2021]: Software and Data Integrity Failures | ||
[REFERENCES] | ||
- https://docs.microsoft.com/en-us/dotnet/standard/serialization/binaryformatter-security-guide | ||
rule: | ||
pattern: new BinaryFormatter() | ||
ESS-ENN marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
id: data-contract-resolver | ||
language: csharp | ||
note: >- | ||
[CWE-502]: Deserialization of Untrusted Data | ||
[OWASP A08:2017]: Insecure Deserialization | ||
[OWASP A08:2021]: Software and Data Integrity Failures | ||
[REFERENCES] | ||
- https://docs.microsoft.com/en-us/dotnet/standard/serialization/binaryformatter-security-guide | ||
message: >- | ||
Use DataContractResolver if you are sure that the data is safe to deserialize. | ||
severity: warning | ||
rule: | ||
pattern: | | ||
class $DCR : DataContractResolver { $$$ } | ||
ESS-ENN marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
id: html-raw-json | ||
language: csharp | ||
message: >- | ||
Avoid using '@Html.Raw(Json.Encode())', '@Html.Raw(JsonConvert.SerializeObject())' or '@Html.Raw().ToJson()' to prevent Cross-Site Scripting (XSS) attacks. | ||
Use '@Html.Raw()' only when necessary and ensure that the data is properly sanitized. | ||
For more information checkout the references. | ||
note: >- | ||
[CWE-79]: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') | ||
[OWASP Top 10 2017]: A07:2017 - Cross-Site Scripting (XSS) | ||
[OWASP Top 10 2021]: A03:2021 - Injection | ||
[REFERENCES] | ||
- https://owasp.org/Top10/A03_2021-Injection | ||
severity: warning | ||
rule: | ||
any: | ||
- pattern: '@Html.Raw(Json.Encode($$$))' | ||
- pattern: '@Html.Raw(JsonConvert.SerializeObject($$$))' | ||
- pattern: '@Html.Raw($$$ToJson($$$))' |
12 changes: 12 additions & 0 deletions
12
rules/csharp/security/insecure-fspickler-deserialization.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
id: insecure-fspickler-deserialization | ||
severity: warning | ||
language: csharp | ||
message: Avoid using FSPickler, it is insecure and can lead to remote code execution | ||
note: >- | ||
[CWE-502]: Deserialization of Untrusted Data | ||
[OWASP A08:2017]: Insecure Deserialization | ||
[OWASP A08:2021]: Software and Data Integrity Failures | ||
[REFERENCES] | ||
- https://mbraceproject.github.io/FsPickler/tutorial.html#Disabling-Subtype-Resolution | ||
rule: | ||
pattern: FsPickler.CreateJsonSerializer() | ||
ESS-ENN marked this conversation as resolved.
Show resolved
Hide resolved
|
12 changes: 12 additions & 0 deletions
12
rules/csharp/security/insecure-netdatacontract-deserialization.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
id: insecure-netdatacontract-deserialization | ||
severity: warning | ||
language: csharp | ||
message: Avoid using NetDataContractSerializer, it is insecure and can lead to remote code execution | ||
note: >- | ||
[CWE-502]: Deserialization of Untrusted Data | ||
[OWASP A08:2017]: Insecure Deserialization | ||
[OWASP A08:2021]: Software and Data Integrity Failures | ||
[REFERENCES] | ||
- https://docs.microsoft.com/en-us/dotnet/api/system.runtime.serialization.netdatacontractserializer?view=netframework-4.8 | ||
rule: | ||
pattern: new NetDataContractSerializer() | ||
ESS-ENN marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
id: los-formatter | ||
language: csharp | ||
message: 'Avoid using LosFormatter, it is insecure and can lead to remote code execution' | ||
severity: warning | ||
note: >- | ||
[CWE-502]: Deserialization of Untrusted Data | ||
[OWASP A08:2017]: Insecure Deserialization | ||
[OWASP A08:2021]: Software and Data Integrity Failures | ||
[REFERENCES] | ||
- https://docs.microsoft.com/en-us/dotnet/api/system.web.ui.webcontrols.losformatter?view=netframework-4.8 | ||
rule: | ||
pattern: new LosFormatter() | ||
ESS-ENN marked this conversation as resolved.
Show resolved
Hide resolved
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.