Code Monkey home page Code Monkey logo

security-code-scan's People

Contributors

agametov avatar eloisetaylor5693 avatar felickz avatar h3xstream avatar indy-singh avatar jarlob avatar kevin-montrose avatar langriklol avatar m0sa avatar mcwww avatar nateplumm avatar obilodeau avatar siderale avatar sjmakin avatar spointlectra avatar tillig avatar viktorijaado avatar waldenl avatar watfordgnf avatar zaichenko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

security-code-scan's Issues

False Positive for Open Redirect

Are cleansing functions taken into consideration by the analyzer? Not just for open redirect but also xss and other vulnerabilities that need sanitizing.

This still shows a warning:

//if (!string.IsNullOrEmpty(model.ReturnUrl))
if (Url.IsLocalUrl(model.ReturnUrl))
{
    return Redirect(model.ReturnUrl);
}

The only way to get rid of the warning is to hard code the url string which isn't practical...
return Redirect("www.google.com");

Add System.Data.SQLite.SQLiteCommand injection detection

        public static void Get(string input)
        {
            string query = "SELECT * FROM aaa WHERE Name = '" + input + "'";
            SQLiteCommand command = new SQLiteCommand(query, Database.DBconnection);
            //command.Parameters.AddWithValue("@pInput", input);

            try
            {
                Database.OpenConn();
                DbDataReader output = command.ExecuteReader();

Analyzing VB.net solution with loop variable declaration outside of the loop

Hi,

We are looking at using Security-Code-Scan to provide static code analysis with security in mind, however running a scan on some legacy VB.net code I found an issue which stops the TaintAnalyzer from going through a method.

The simplest example I have boiled it down to is the ability in VB.net (though this seems impossible in C#) to declare a loop variable outside of the loop.

e.g.
the code:

 Sub Main(args As String())
    For Each argItem As String In args
        Console.WriteLine(argItem)
    Next
End Sub

appears to be analyzed fine, however moving the declaration of argItem out of the loop as in:

Sub Main(args As String())
    Dim argItem As String

    For Each argItem In args
        Console.WriteLine(argItem)
    Next
End Sub

causes the error:
Severity Code Description Project File Line Suppression State
Warning AD0001 Analyzer 'SecurityCodeScan.Analyzers.Taint.TaintAnalyzer' threw an exception of type 'System.Exception' with message 'Unhandled exception while visiting method Sub Main(args As String())
argItem As String

    For Each argItem In args
        Console.WriteLine(argItem)
    Next
End Sub : Unable to cast object of type 'Microsoft.CodeAnalysis.VisualBasic.Syntax.IdentifierNameSyntax' to type 'Microsoft.CodeAnalysis.VisualBasic.Syntax.VariableDeclaratorSyntax'.'.	SecurityCodeScanBreaker		1	Active

image

Add C# 7.0 support

There are few tests commented out with

// todo: add C# 7.0 support

in the code. Switching to a newer Roslyn analyzers nuget possibly is needed.

Move read-only properties that are constant in fact to the config

Currently hardcoded in the taint analyzer:

                        case "System.String.Empty":
                        case "System.IntPtr.Zero":
                        case "System.IO.Path.AltDirectorySeparatorChar":
                        case "System.IO.Path.DirectorySeparatorChar":
                        case "System.IO.Path.InvalidPathChars":
                        case "System.IO.Path.PathSeparator":
                        case "System.IO.Path.VolumeSeparatorChar":

False negatives in alias directive case

Looks like the optimization based on node name:

            var objectCreation = nodeHelper.GetNameNode(ctx.Node);
            if(!objectCreation.ToString().Contains("JavaScriptSerializer"))
                return;

misses some corner cases:

using System.Web.Script.Serialization;
using JSS = System.Web.Script.Serialization.JavaScriptSerializer;

namespace VulnerableApp
{
    class Test
    {
        private JSS serializer = new JSS(new SimpleTypeResolver());
    }
}

It is just an example, all code should be reviewed.
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/using-directive

Works on Visual Studio 2015 or higher. Free Visual Studio Community and paid Professional and Enterprise editions are supported.

Please can you clarify the following statement:

"Works on Visual Studio 2015 or higher. Free Visual Studio Community and paid Professional and Enterprise editions are supported."

That appear on https://security-code-scan.github.io/

I, and colleague have Visual Studio 2015 professional. Do we need to pay any licencing for this extension, or is it completely free to use?

What am I supposed to see if the install worked in VS2017

I downloaded and install your extension from https://marketplace.visualstudio.com/items?itemName=JaroslavLobacevski.SecurityCodeScan after hearing about it on https://marketplace.visualstudio.com/items?itemName=PhilippeArteau.RoslynSecurityGuard
What I've done so far:

  • I reopened VS2017 and my my solution in
  • I blindly added AdditionalFileItemNames>$(AdditionalFileItemNames);Content</AdditionalFileItemNames> to my .csproj
  • I checked [x] Editor > C# (or Basic) > Advanced > “Enable full solution analysis”
  • I did a rebuild (noticed nothing, I I know my app has XSS and CSRF issues since I've only partially covered my public class ServicesController : ApiController [HttpPost]s with [AntiForgeryToken]
  • I rebooted VS2017 and did another build, still nothing in Error List.

Did I miss something?

Add IgnorableServerCertificateErrors.Add warning

where IgnorableServerCertificateErrors is IList<ChainValidationResult> like:

var myWebSocket = new MessageWebSocket();
myWebSocket.Information.IgnorableServerCertificateErrors.Add(ChainValidationResult.Untrusted);

It is not specific to MessageWebSocket as exists in HttpBaseProtocolFilter too.

Detect when certificateValidationMode is set to None or Custom

Support configuration file schema changes and multiple SCS installations

A continuation of #15

There may be incompatible changes in configuration schema between versions. To support that:

  1. A configuration file should has a property Version. It is better to have it as a property instead of filename, because configuration files may be per projects.
  2. The version number should be separate from assembly version because there may be no configuration schema changes between different SCS versions.
  3. When SCS is updated it should attempt to (an investigation is needed what is possible):
    • update the config in AppData in VS extension case. Since the location is shared between different installations (vs2015, vs2017 and nugets) the upgrade should create a new file in the folder (version number in the file name).
    • update the config in project when NuGet package is updated or during analysis in VS extension case (Investigate if it is even possible to have two versions of SCS running from NuGet and from VS extension at the same time. If it is, then maybe VS extension should convert the config in memory on the fly only).
  4. If upgrade has failed or the version number is newer than supported SCS should show a fake analysis warning (SCS_Error1?) when the analysis is kicked off.
    • SCS_Warning for a suggestion to upgrade when doing memory only upgrade?
    • Since a user may change the number manually or the file maybe corrupted SCS_Error is needed if an exception happened during config loading.

Warnings on deserialization where only one argument of two is tainted

For some deserializers like XmlSerializer and DataContractSerializer both type and serialized data have to be tainted to make it exploitable. Currently it gives false positives if only one is:

var deserializer = new XmlSerializer(typeof(MyType));
var my  = deserializer.Deserialize(input) as MyType;

It doesn't mean the MyType cannot be used as a gadget, the class should be investigated further.

  • Keep current behavior for Auditing mode
  • Show the warning only if both arguments are tainted

False positive when serializing with XmlSerializer

There should be no warning because it serializes.

        static void Serialize(Type type, object data)
        {
            XmlSerializer xs = new XmlSerializer(type);
            StreamWriter writer = File.CreateText("");
            xs.Serialize(writer, data);
            writer.Flush();
            writer.Close();     
        }

Multiple issues in the implementation of XSS analyzer

  1. The check if input value is used in output is incorrect, triggers also:
using System.Web.Mvc;

namespace VulnerableApp
{
    public class TestController : Controller
    {
        [HttpGet]
        public string Get(int sensibleData)
        {
            var x = sensibleData;
            return "value";
        }
    }
}
  1. Input variables that cannot be used to inject javascript like int also trigger the warning.
  2. EncodingMethods array is not used. A variable is considered encoded if used as an argument to any function.

Should be rewritten similar to CookieAnalyzer.

Ignore TypeNameHandling when a deep clone is done

Although it doesn't clone private members...

        public T DeepClone<T>(T source)
        {
            var serializeSettings = new JsonSerializerSettings {TypeNameHandling = TypeNameHandling.All};
            var serialized = JsonConvert.SerializeObject(source, serializeSettings);
            return JsonConvert.DeserializeObject<T>(serialized, serializeSettings);
        }

Needs to use taint analysis or something similar to XXE analyzers.

Add ValidateRequestMode aspx analyzer

Starting with ASP.NET 4.5 you can disable request validation at the individual server control level by setting ValidateRequestMode to "Disabled".
<asp:TextBox ID="txtASPNet" ValidateRequestMode="Disabled" runat="server" />

Suppress errors in generated code

I have some ADO dataset generated code, where I see many instances of the following:

SCS0007 XML parsing vulnerable to XXE

The default setting for VS is supposed to suppress code analysis errors on generated code but SCS does not seem to do so. Is there a workaround? For example, is it possible to suppress analysis on the entire class via the global suppression file?

Some Security Warnings in VSTS Build Overview missing

First, thanks for the effort building a free library with some security related checks 👍

I want to get an overview of all security warnings in a project. For prototyping this I've created a VSTS build for the WebGoat.NET sample project. The analyzer is picked up fine and I get the 22 expected errors in the detailed log:

screenshot from 2018-05-09 11-34-45

When taking a look at the Build overview, I'm missing however half of the warnings:

screenshot from 2018-05-09 11-35-09

I'm not sure whether this is a configuration issue on my side or something wrong in VSTS. Do you have any experience with this?

Move configuration settings out of manifest into external file

Or at least allow overriding the built in settings with settings from external file. If SCS is installed as extension it should be in the extension folder. In nuget case - per project file.

  • Combine different settings yml files into one.
  • Load and merge rules: Built in, global, project.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.