Message from discussion
Signing undefined values: signature_mismatch
MIME-Version: 1.0
Received: by 10.150.217.14 with SMTP id p14mr108387ybg.28.1227741108910; Wed,
26 Nov 2008 15:11:48 -0800 (PST)
Date: Wed, 26 Nov 2008 15:11:48 -0800 (PST)
X-IP: 204.16.157.178
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.4)
Gecko/2008102920 Firefox/3.0.4 (.NET CLR 3.5.30729),gzip(gfe),gzip(gfe)
Message-ID: <035c9d23-cee3-4f91-b597-16d8396f2edd@c1g2000yqg.googlegroups.com>
Subject: Signing undefined values: signature_mismatch
From: Igor Gariev <gar...@hotmail.com>
To: "Net::OpenID for Perl" <openid-perl@googlegroups.com>
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Greetings,
currently (revision 160) server and consumer interpret missing
arguments differently, that leads to signature_mismatch error.
To calculate/check signature, a token string (list of "key:value"
pairs joined by new line) is constructed, where keys are listed in
'openid.signed' param.
Server skips missing values completely (Net/OpenID/Server.pm, line
294):
foreach my $f (@sign) {
next unless defined $arg{$f};
$token_contents .= "$f:$arg{$f}\n";
...
Consumer uses empty strings instead of missed values, and adds strings
like "key:" to token (Net/OpenID/Consumer.pm, line 789):
foreach my $param (split(/,/, $signed)) {
my $val = $self->args("openid.$param");
$token .= "$param:$val\n";
Signatures of (thus) different tokens certainly don't match. I had the
problem with 'op_endpoint' parameter (Net/OpenID/Server.pm, line 269)
Regretfully, OpenID specification says nothing about how to sign
missing values.
Possible solutions:
1. Don't put keys of undefied/empty values into 'openid.signed' list
at all. Pro: this will solve all problems of portability between
different libraries/languages. Con: it's not possible to sign empty
values (to sign that some values is missing), so intruder may put any
value instead of missing one.
2. Both client and server must process all keys in 'openid.signed'
list and treat missing values as empty strings. Pro: this is secure
solution, that seems to work with previous version of at least Perl
library. Con: since specification says nothing, it's not guaranteed
that all implementation will follow this practice.
Diff for #2 is below:
--- Net-OpenID-Server/lib/Net/OpenID/Server.pm (revision 160)
+++ Net-OpenID-Server/lib/Net/OpenID/Server.pm (working copy)
@@ -291,7 +291,6 @@
my @arg; # arguments we'll append to the URL
my $token_contents = "";
foreach my $f (@sign) {
- next unless defined $arg{$f};
$token_contents .= "$f:$arg{$f}\n";
push @arg, "openid.$f" => $arg{$f};
delete $arg{$f};