[PATCH] anti-forgery
Brought to you by:
ftobin
|
From: Billy D. <bi...@da...> - 2000-10-03 10:57:24
|
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Here's a patch to do forgery checks. They are enabled by default.
You'll need to get String::Approx from CPAN for this to work.
I've been testing it out and it's working really well.
I hope GPG doesn't mangle my patch..
diff --exclude Makefile --exclude blib --exclude CVS -ru pgpenvelope.orig/Makefile.PL pgpenvelope/Makefile.PL
- --- pgpenvelope.orig/Makefile.PL Tue Oct 3 06:32:54 2000
+++ pgpenvelope/Makefile.PL Tue Oct 3 06:30:53 2000
@@ -14,6 +14,7 @@
'Term::ReadLine::Gnu' => 1.01,
'GnuPG::Interface' => 0.10,
'Class::MethodMaker' => 0.96,
+ 'String::Approx' => 3.13,
};
print
diff --exclude Makefile --exclude blib --exclude CVS -ru pgpenvelope.orig/lib/PGPEnvelope/Config.pm pgpenvelope/lib/PGPEnvelope/Config.pm
- --- pgpenvelope.orig/lib/PGPEnvelope/Config.pm Tue Oct 3 06:32:54 2000
+++ pgpenvelope/lib/PGPEnvelope/Config.pm Tue Oct 3 06:21:56 2000
@@ -171,6 +171,16 @@
'signing-key'
=> PGPEnvelope::Config::Definition->new
( ARGCOUNT => 1 ),
+
+ 'forgery-warning'
+ => PGPEnvelope::Config::Definition->new
+ ( ARGCOUNT => 1,
+ DEFAULT => '[WARNING:not from pgpenvelope]',
+ ),
+
+ 'do-forgery-check'
+ => PGPEnvelope::Config::Definition->new
+ ( DEFAULT => 1 ),
);
@@ -321,6 +331,17 @@
#top-border = $defs{'top-border'}->{DEFAULT}
#info-top-border = $defs{'info-top-border'}->{DEFAULT}
#info-bottom-Border = $defs{'info-bottom-border'}->{DEFAULT}
+
+# An attacker could try to send you a forged message that looks as
+# though it had been passed through pgpenvelope_decrypt
+# and been verified.
+# If pgpenvelope_decrypt detects an input line matching any of your
+# pgpenvelope message borders, it will prepend a warning message
+# to those lines to warn you of a possible forgery unless you disable
+# the forgery-warning option by setting do-forgery-check to 0.
+
+#forgery-warning = $defs{'forgery-warning'}->{DEFAULT}
+#do-forgery-check = $defs{'do-forgery-check'}->{DEFAULT}
# This specifies if you only want to see the first uid and
# subkey information for keys to encrypt to when encrypting
diff --exclude Makefile --exclude blib --exclude CVS -ru pgpenvelope.orig/pgpenvelope pgpenvelope/pgpenvelope
- --- pgpenvelope.orig/pgpenvelope Tue Oct 3 06:32:54 2000
+++ pgpenvelope/pgpenvelope Tue Oct 3 06:51:35 2000
@@ -121,7 +121,7 @@
* ^-----BEGIN PGP
pgpenvelope-backup
- - :0 abfw
+ :0 bfw
| (path_to)/pgpenvelope_decrypt --filter
diff --exclude Makefile --exclude blib --exclude CVS -ru pgpenvelope.orig/pgpenvelope_decrypt pgpenvelope/pgpenvelope_decrypt
- --- pgpenvelope.orig/pgpenvelope_decrypt Tue Oct 3 06:32:54 2000
+++ pgpenvelope/pgpenvelope_decrypt Tue Oct 3 06:22:46 2000
@@ -32,6 +32,8 @@
use IO::File;
use IO::Seekable;
use FindBin;
+use String::Approx qw( aindex );
+
use sigtrap 'handler' => 'die_signal_handler', 'normal-signals';
use GnuPG::Interface 0.10;
@@ -96,8 +98,14 @@
$gnupg->options->meta_interactive( not $is_filter );
$gnupg->gnupg_call( $program_call );
+my $do_forgery_check = $config->get('do-forgery-check');
+
PGP_MESSAGE: while ( <STDIN> )
{
+ if($do_forgery_check and &detect_forged_borders($_)){
+ $_ = $config->get('forgery-warning').$_;
+ }
+
unless ( /^-----BEGIN PGP / )
{
print STDOUT $_;
@@ -301,4 +309,30 @@
{
print $fh $zeros;
}
+}
+
+#
+# Detect forged pgpenvelope borders.
+#
+# Check a line of data.
+# Perform an approximate match against the pgpenvelope border messages.
+# If the match is not flush against the left side, then there is no
+# cause for alarm, and a 0 is returned
+#
+# return 1 if any lines were within a 10% margin. (User should be warned).
+# This means that up to 9 characters in 10 correctly matched
+# his border string without any edits.
+# return 0 if everything is okay.
+#
+sub detect_forged_borders
+{
+ my ($line) = @_;
+ my @bordernames = qw( top-border info-top-border info-bottom-border);
+ my @borders = map { $config->get($_) } @bordernames;
+
+ for my $b (@borders) {
+ return 1 if aindex($b, $line) == 0;
+ }
+ return 0;
}
+
- --
"The Funk, the whole Funk, and nothing but the Funk."
Linux barcode software mirror: http://dadadada.net/cuecat
Billy Donahue <mailto:bi...@da...>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.3 (GNU/Linux)
Comment: pgpenvelope 2.9.0 - http://pgpenvelope.sourceforge.net/
iD8DBQE52buP+2VvpwIZdF0RAgckAKCB0YJDGhsXVE1Q0MFT12np8TsKJQCeOlYW
F29jKTHJiy4ST98SzEsBQ7Q=
=s1Hg
-----END PGP SIGNATURE-----
|