line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
26
|
|
|
26
|
|
218
|
use strict; |
|
26
|
|
|
|
|
77
|
|
|
26
|
|
|
|
|
827
|
|
2
|
26
|
|
|
26
|
|
165
|
use warnings; |
|
26
|
|
|
|
|
69
|
|
|
26
|
|
|
|
|
1440
|
|
3
|
|
|
|
|
|
|
package Net::SAML2::XML::Util; |
4
|
|
|
|
|
|
|
our $VERSION = '0.74'; # VERSION |
5
|
|
|
|
|
|
|
|
6
|
26
|
|
|
26
|
|
182
|
use XML::LibXML; |
|
26
|
|
|
|
|
81
|
|
|
26
|
|
|
|
|
298
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# use 'our' on v5.6.0 |
9
|
26
|
|
|
26
|
|
5548
|
use vars qw($VERSION @EXPORT_OK %EXPORT_TAGS $DEBUG); |
|
26
|
|
|
|
|
93
|
|
|
26
|
|
|
|
|
2238
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
$DEBUG = 0; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# We are exporting functions |
14
|
26
|
|
|
26
|
|
228
|
use base qw/Exporter/; |
|
26
|
|
|
|
|
78
|
|
|
26
|
|
|
|
|
6758
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# Export list - to allow fine tuning of export table |
17
|
|
|
|
|
|
|
@EXPORT_OK = qw( no_comments ); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# ABSTRACT: XML Util class |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub no_comments { |
24
|
39
|
|
|
39
|
1
|
96
|
my $xml = shift; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# Remove comments from XML to mitigate XML comment auth bypass |
27
|
39
|
|
|
|
|
279
|
my $dom = XML::LibXML->load_xml( |
28
|
|
|
|
|
|
|
string => $xml, |
29
|
|
|
|
|
|
|
no_network => 1, |
30
|
|
|
|
|
|
|
load_ext_dtd => 0, |
31
|
|
|
|
|
|
|
expand_entities => 0 |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
|
34
|
39
|
|
|
|
|
17819
|
for my $comment_node ($dom->findnodes('//comment()')) { |
35
|
8
|
|
|
|
|
310
|
$comment_node->parentNode->removeChild($comment_node); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
39
|
|
|
|
|
2164
|
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 - XML Util class |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 VERSION |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
version 0.74 |
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 AUTHORS |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=over 4 |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=item * |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Chris Andrews <chrisa@cpan.org> |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=item * |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Timothy Legge <timlegge@gmail.com> |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=back |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
This software is copyright (c) 2023 by Venda Ltd, see the CONTRIBUTORS file for others. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
93
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=cut |