Skip to content
Merged
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
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ This section outlines essential rules for secure coding practices:
|[SLC_SC0004](https://github.com/SkylineCommunications/Skyline.DataMiner.Utils.SecureCoding/blob/main/docs/Rules/SLC_SC0004.md)|Usage|Avoid deserializing json strings by using Newtonsoft directly.|⚠️|✔️|✔️|
|[SLC_SC0005](https://github.com/SkylineCommunications/Skyline.DataMiner.Utils.SecureCoding/blob/main/docs/Rules/SLC_SC0005.md)|Usage|Certificate callbacks should not always evaluate to true|⚠️|✔️|❌|
|[SLC_SC0006](https://github.com/SkylineCommunications/Skyline.DataMiner.Utils.SecureCoding/blob/main/docs/Rules/SLC_SC0006.md)|Usage|Ensure secure loading of Assemblies|⚠️|✔️|✔️|
|[SLC_SC0007](https://github.com/SkylineCommunications/Skyline.DataMiner.Utils.SecureCoding/blob/main/docs/Rules/SLC_SC0007.md)|Usage|Avoid insecure cryptographic algorithms|⚠️|✔️|❌|

<!-- rules -->

Expand All @@ -70,6 +71,9 @@ dotnet_diagnostic.SLC_SC0005.severity = warning

# SLC_SC0006: Ensure secure loading of Assemblies
dotnet_diagnostic.SLC_SC0006.severity = warning

# SLC_SC0007: Avoid insecure cryptographic algorithms
dotnet_diagnostic.SLC_SC0006.severity = warning
```

# .editorconfig - all rules disabled
Expand All @@ -92,4 +96,7 @@ dotnet_diagnostic.SLC_SC0005.severity = none

# SLC_SC0006: Ensure secure loading of Assemblies
dotnet_diagnostic.SLC_SC0006.severity = none

# SLC_SC0007: Avoid insecure cryptographic algorithms
dotnet_diagnostic.SLC_SC0006.severity = none
```
7 changes: 7 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
|[SLC_SC0004](https://github.com/SkylineCommunications/Skyline.DataMiner.Utils.SecureCoding/blob/main/docs/Rules/SLC_SC0004.md)|Usage|Avoid deserializing json strings by using Newtonsoft directly.|<span title='Warning'>⚠️</span>|✔️|✔️|
|[SLC_SC0005](https://github.com/SkylineCommunications/Skyline.DataMiner.Utils.SecureCoding/blob/main/docs/Rules/SLC_SC0005.md)|Usage|Certificate callbacks should not always evaluate to true|<span title='Warning'>⚠️</span>|✔️|❌|
|[SLC_SC0006](https://github.com/SkylineCommunications/Skyline.DataMiner.Utils.SecureCoding/blob/main/docs/Rules/SLC_SC0006.md)|Usage|Ensure secure loading of Assemblies|<span title='Warning'>⚠️</span>|✔️|✔️|
|[SLC_SC0007](https://github.com/SkylineCommunications/Skyline.DataMiner.Utils.SecureCoding/blob/main/docs/Rules/SLC_SC0007.md)|Usage|Avoid insecure cryptographic algorithms|<span title='Warning'>⚠️</span>|✔️|❌|


# .editorconfig - default values
Expand All @@ -29,6 +30,9 @@ dotnet_diagnostic.SLC_SC0005.severity = warning

# SLC_SC0006: Ensure secure loading of Assemblies
dotnet_diagnostic.SLC_SC0006.severity = warning

# SLC_SC0007: Avoid insecure cryptographic algorithms
dotnet_diagnostic.SLC_SC0007.severity = warning
```

# .editorconfig - all rules disabled
Expand All @@ -51,4 +55,7 @@ dotnet_diagnostic.SLC_SC0005.severity = none

# SLC_SC0006: Ensure secure loading of Assemblies
dotnet_diagnostic.SLC_SC0006.severity = none

# SLC_SC0007: Avoid insecure cryptographic algorithms
dotnet_diagnostic.SLC_SC0007.severity = none
```
48 changes: 48 additions & 0 deletions docs/Rules/SLC_SC0007.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# SLC_SC0007 - Avoid insecure cryptographic algorithms

The CryptographicAnalyzer detects the usage of insecure or deprecated cryptographic algorithms in C# applications. It flags both hashing and encryption algorithms that are widely considered insecure and encourages the use of modern, secure alternatives.

Using outdated cryptographic primitives can leave your application vulnerable to a wide range of attacks, including collision attacks, preimage attacks, and key recovery.

## Triggered When

This analyzer triggers when your code:

- Instantiates insecure cryptographic algorithm types (e.g., `new MD5CryptoServiceProvider()`)

- Calls static `Create()` methods on insecure cryptographic algorithm classes (e.g., `MD5.Create()`)


## Insecure Hashing Algorithms Detected

The following hashing algorithms are considered insecure and will trigger this diagnostic:

- MD5 (`System.Security.Cryptography.MD5`, `MD5CryptoServiceProvider`)

- SHA1 (`System.Security.Cryptography.SHA1`, `SHA1Managed`)


**Suggested Alternatives:**

- SHA256

- SHA384

- SHA512


## Insecure Encryption Algorithms Detected

The following encryption algorithms are considered insecure and will trigger this diagnostic:

- DES

- TripleDES

- RC2


**Suggested Alternative:**

- AES (`Aes`, `AesManaged`, `AesCryptoServiceProvider`)
````