line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
25
|
|
|
25
|
|
186
|
use strict; |
|
25
|
|
|
|
|
65
|
|
|
25
|
|
|
|
|
754
|
|
2
|
25
|
|
|
25
|
|
163
|
use warnings; |
|
25
|
|
|
|
|
72
|
|
|
25
|
|
|
|
|
1442
|
|
3
|
|
|
|
|
|
|
package Net::SAML2::XML::Util; |
4
|
|
|
|
|
|
|
our $VERSION = '0.72'; # TRIAL VERSION |
5
|
|
|
|
|
|
|
|
6
|
25
|
|
|
25
|
|
165
|
use XML::LibXML; |
|
25
|
|
|
|
|
54
|
|
|
25
|
|
|
|
|
253
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# use 'our' on v5.6.0 |
9
|
25
|
|
|
25
|
|
4545
|
use vars qw($VERSION @EXPORT_OK %EXPORT_TAGS $DEBUG); |
|
25
|
|
|
|
|
58
|
|
|
25
|
|
|
|
|
1955
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
$DEBUG = 0; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# We are exporting functions |
14
|
25
|
|
|
25
|
|
220
|
use base qw/Exporter/; |
|
25
|
|
|
|
|
69
|
|
|
25
|
|
|
|
|
5888
|
|
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
|
88
|
my $xml = shift; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# Remove comments from XML to mitigate XML comment auth bypass |
27
|
39
|
|
|
|
|
247
|
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
|
|
|
|
|
16459
|
for my $comment_node ($dom->findnodes('//comment()')) { |
35
|
8
|
|
|
|
|
273
|
$comment_node->parentNode->removeChild($comment_node); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
39
|
|
|
|
|
2038
|
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.72 |
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 |