line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
25
|
|
|
25
|
|
226
|
use strict; |
|
25
|
|
|
|
|
75
|
|
|
25
|
|
|
|
|
870
|
|
2
|
25
|
|
|
25
|
|
196
|
use warnings; |
|
25
|
|
|
|
|
64
|
|
|
25
|
|
|
|
|
1623
|
|
3
|
|
|
|
|
|
|
package Net::SAML2::XML::Util; |
4
|
|
|
|
|
|
|
our $VERSION = '0.73'; # VERSION |
5
|
|
|
|
|
|
|
|
6
|
25
|
|
|
25
|
|
190
|
use XML::LibXML; |
|
25
|
|
|
|
|
64
|
|
|
25
|
|
|
|
|
298
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# use 'our' on v5.6.0 |
9
|
25
|
|
|
25
|
|
5433
|
use vars qw($VERSION @EXPORT_OK %EXPORT_TAGS $DEBUG); |
|
25
|
|
|
|
|
442
|
|
|
25
|
|
|
|
|
2422
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
$DEBUG = 0; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# We are exporting functions |
14
|
25
|
|
|
25
|
|
255
|
use base qw/Exporter/; |
|
25
|
|
|
|
|
118
|
|
|
25
|
|
|
|
|
7065
|
|
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
|
106
|
my $xml = shift; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# Remove comments from XML to mitigate XML comment auth bypass |
27
|
39
|
|
|
|
|
312
|
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
|
|
|
|
|
19113
|
for my $comment_node ($dom->findnodes('//comment()')) { |
35
|
8
|
|
|
|
|
320
|
$comment_node->parentNode->removeChild($comment_node); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
39
|
|
|
|
|
2394
|
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.73 |
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 |