line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::SAML2::XML::Util; |
2
|
|
|
|
|
|
|
|
3
|
13
|
|
|
13
|
|
100
|
use strict; |
|
13
|
|
|
|
|
29
|
|
|
13
|
|
|
|
|
469
|
|
4
|
13
|
|
|
13
|
|
70
|
use warnings; |
|
13
|
|
|
|
|
28
|
|
|
13
|
|
|
|
|
338
|
|
5
|
|
|
|
|
|
|
|
6
|
13
|
|
|
13
|
|
67
|
use XML::LibXML; |
|
13
|
|
|
|
|
29
|
|
|
13
|
|
|
|
|
78
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# use 'our' on v5.6.0 |
9
|
13
|
|
|
13
|
|
1866
|
use vars qw($VERSION @EXPORT_OK %EXPORT_TAGS $DEBUG); |
|
13
|
|
|
|
|
32
|
|
|
13
|
|
|
|
|
1265
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
$DEBUG = 0; |
12
|
|
|
|
|
|
|
our $VERSION = '0.41'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# We are exporting functions |
15
|
13
|
|
|
13
|
|
99
|
use base qw/Exporter/; |
|
13
|
|
|
|
|
27
|
|
|
13
|
|
|
|
|
3625
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# Export list - to allow fine tuning of export table |
18
|
|
|
|
|
|
|
@EXPORT_OK = qw( no_comments ); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# ABSTRACT: Net::SAML2::XML::Util - XML Util class |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub no_comments { |
25
|
20
|
|
|
20
|
1
|
52
|
my $xml = shift; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# Remove comments from XML to mitigate XML comment auth bypass |
28
|
20
|
|
|
|
|
169
|
my $dom = XML::LibXML->load_xml( |
29
|
|
|
|
|
|
|
string => $xml, |
30
|
|
|
|
|
|
|
no_network => 1, |
31
|
|
|
|
|
|
|
load_ext_dtd => 0, |
32
|
|
|
|
|
|
|
expand_entities => 0 ); |
33
|
|
|
|
|
|
|
|
34
|
20
|
|
|
|
|
10067
|
for my $comment_node ($dom->findnodes('//comment()')) { |
35
|
0
|
|
|
|
|
0
|
$comment_node->parentNode->removeChild($comment_node); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
20
|
|
|
|
|
1952
|
return $dom; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
__END__ |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=pod |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=encoding UTF-8 |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 NAME |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Net::SAML2::XML::Util - Net::SAML2::XML::Util - XML Util class |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 VERSION |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
version 0.41 |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 SYNOPSIS |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
my $xml = no_comments($xml); |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 NAME |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Net::SAML2::XML::Util - XML Util class. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 METHODS |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head2 no_comments( $xml ) |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Returns the XML passed as plain XML with the comments removed |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
This is to remediate CVE-2017-11427 XML Comments can allow for |
72
|
|
|
|
|
|
|
authentication bypass in SAML2 implementations |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 AUTHOR |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Chris Andrews <chrisa@cpan.org> |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
This software is copyright (c) 2021 by Chris Andrews and Others, see the git log. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
83
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=cut |