CVE-2017-7239 (published 2017-04-10T15:59Z)

Ninka before 1.3.2 might allow remote attackers to obtain sensitive information, manipulate license compliance scan results, or cause a denial of service (process hang) via a crafted filename.

Severity: HIGH
CVSS v2 base score: 7.5 (AV:N/AC:L/Au:N/C:P/I:P/A:P)
CVSS v3 base score: 9.8, CRITICAL (CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H)

Weakness information:
cwe_id: CWE-74
cwe_name: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')
description: The product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.
extended_description: Software or other automated logic has certain assumptions about what constitutes data and control respectively. It is the lack of verification of these assumptions for user-controlled input that leads to injection problems. Injection problems encompass a wide variety of issues -- all mitigated in very different ways and usually attempted in order to alter the control flow of the process. For this reason, the most effective way to discuss these weaknesses is to note the distinct features that classify them as injection weaknesses. The most important issue to note is that all injection problems share one thing in common -- i.e., they allow for the injection of control plane data into the user-controlled data plane. This means that the execution of the process may be altered by sending code in through legitimate data channels, using no other mechanism. While buffer overflows, and many other flaws, involve the use of some further issue to gain execution, injection problems need only for the data to be parsed.
         

Fix information:
repo_url: https://github.com/dmgerman/ninka
commit_details: repo_url: https://github.com/dmgerman/ninka
author: D German
author_date: 2017-04-02 13:57:09-07:00
msg: Addresses  CVE-2017-7239: ninka license identification tool: insufficient escaping of external input
repository: repo_url: https://github.com/dmgerman/ninka
repo_name: dmgerman/ninka
description:  a license identification tool for Source Code
repo_language: Roff
owner: dmgerman
file_changes: filename: Changes
change_type: ModificationType.MODIFY
diff: @@ -1,3 +1,17 @@
+2017-04-02  Daniel M. German  <dmg@uvic.ca>
+
+        These changes address CVE-2017-7239
+
+	* lib/Ninka.pm: upgraded to version to 1.3.2
+
+	* Makefile.PL: Added IO::CaptureOutput to dependencies
+
+	* CommentExtractor.pm:
+
+	- replaced call to system with a single argument with a list of arguments.
+
+	- replaced the use of open3 with captureoutput to simplify the code
+
 2017-03-26  Daniel M. German  <dmg@uvic.ca>
 
 	* lib/Ninka/CommentExtractor.pm (execute_command): 

programming_language: Markdown
filename: Makefile.PL
change_type: ModificationType.MODIFY
diff: @@ -27,6 +27,8 @@ WriteMakefile(
         'Getopt::Std' => '0',
         'IPC::Open3' => '0',
         'Spreadsheet::WriteExcel' => '0',
+        'IO::CaptureOutput' => '0',
+                  
     },
     TEST_REQUIRES => {
         'File::Temp' => '0',

programming_language: Perl
filename: Ninka.pm
change_type: ModificationType.MODIFY
diff: @@ -9,7 +9,7 @@ use Ninka::SentenceExtractor;
 use Ninka::SentenceFilter;
 use Ninka::SentenceTokenizer;
 
-our $VERSION = '1.3.1';
+our $VERSION = '1.3.2';
 
 sub process_file {
     my ($input_file, $create_intermediary_files, $verbose) = @_;

programming_language: Perl
filename: CommentExtractor.pm
change_type: ModificationType.MODIFY
diff: @@ -4,6 +4,7 @@ use strict;
 use warnings;
 use IPC::Open3 'open3';
 use Symbol 'gensym';
+use IO::CaptureOutput qw/capture_exec/;
 
 sub new {
     my ($class, %args) = @_;
@@ -21,11 +22,11 @@ sub new {
 sub execute {
     my ($self) = @_;
 
-    my $command = $self->determine_comments_command();
-    my $comments = execute_command($command);
-    if ($command =~ /^comments/ && length($comments) == 0) {
-        $command = create_head_cmd($self->{input_file}, 700);
-        $comments = execute_command($command);
+    my @command = $self->determine_comments_command();
+    my $comments = execute_command(@command);
+    if ($command[0] =~ /^comments/ && length($comments) == 0) {
+        @command = create_head_cmd($self->{input_file}, 700);
+        $comments = execute_command(@command);
     }
 
     return $comments;
@@ -45,7 +46,7 @@ sub determine_comments_command {
         } elsif ($ext =~ /^(java|c|cpp|h|cxx|c\+\+|cc)$/) {
             my $comments_binary = 'comments';
             if (`which $comments_binary` ne '') {
-                return "$comments_binary -c1 '$input_file' 2> /dev/null";
+                return ($comments_binary, "-c1", $input_file);
             } else {
                 return create_head_cmd($input_file, 400);
             }
@@ -60,10 +61,27 @@ sub determine_comments_command {
 sub create_head_cmd {
     my ($input_file, $count_lines) = @_;
 
-    return "head -$count_lines $input_file";
+    return ("head",  "-$count_lines",  $input_file);
 }
 
 sub execute_command {
+    my (@command) = @_;
+    # make sure we have more than one element in the array
+    #    otherwise system will use the shell to do the execution
+    die "command (@command) seems to be missing parameters" unless (scalar(@command) > 1);
+
+    my ($stdout, $error, $success, $status) = capture_exec( @command );
+
+    my $commandSt = join(' ', @command);
+    die "execution of program [$commandSt] failed: status [$status], error [$error]" if ($status != 0);
+
+    return $stdout;
+}
+
+
+# insecure execute command. Leave here for the time being
+# it is dead code
+sub execute_command_old {
     my ($command) = @_;
 
     if ($command =~ /&/) {

programming_language: Perl