Skip to content

Commit 78faf2c

Browse files
Merge pull request #483 from OCSInventory-NG/fix-xss
fix(server): return invalid agent if unauthorized characters for user…
2 parents d886638 + f81e28a commit 78faf2c

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

Apache/Ocsinventory/Server/Modperl1.pm

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,15 @@ sub _set_http_content_type{
7373

7474
sub _get_http_header{
7575
my ($header, $r) = @_;
76-
return $r->headers_in->{$header};
76+
my $value = $r->headers_in->{$header};
77+
return unless defined $value;
78+
79+
$value =~ s/[\x00-\x08\x0B\x0C\x0E-\x1F]//g;
80+
return "Invalid_agent" if $value =~ /[<>"';]/;
81+
82+
return $value;
7783
}
84+
7885
sub _send_http_headers{
7986
my $r = shift;
8087
$r->send_http_header;

Apache/Ocsinventory/Server/Modperl2.pm

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,13 @@ sub _set_http_content_type{
7171

7272
sub _get_http_header{
7373
my ($header, $r) = @_;
74-
return $r->headers_in->{$header};
74+
my $value = $r->headers_in->{$header};
75+
return unless defined $value;
76+
77+
$value =~ s/[\x00-\x08\x0B\x0C\x0E-\x1F]//g;
78+
return "Invalid_agent" if $value =~ /[<>"';]/;
79+
80+
return $value;
7581
}
7682

7783
sub _send_http_headers{

0 commit comments

Comments
 (0)