mailauth 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b16ed1cec4ffbdbe20c947b204e28b417003a2c175622b3cc404cb902fe48535
4
- data.tar.gz: a2c0c00468a940c523d727339503bce49317f756db2c1a886659601a295efc49
3
+ metadata.gz: 49dfab12d1bcd9e138fd09d613b66d5ffa150cbd4d73ce381e10a07a6aa3e3f2
4
+ data.tar.gz: 99e7290474ee3fe5054e05b23041cdf93b9f91d174f7d7ed23dd7ded0743b9e1
5
5
  SHA512:
6
- metadata.gz: 2a157fe9a86b4cc1e8ac95a433a0c31cc9235c71057900510be4426b37303b0b8099a23506ea46834693304923215e40c46b7c5a5b7843bfdf23445999835b54
7
- data.tar.gz: e792cb0cc915924ecaa8205aa9023e756c9ad96e9ecec6ef9abd3653d634f875824b49ac5c8fc957e76ae192c3a11a75dff5da145809cbead1fc23f9353fbcfe
6
+ metadata.gz: 5381265ba7b84d464781bbca0428c1ceec111b93eea103095545301d381a4b4bfbfc55fb34bf47e5ffd8921700a531bb83d965dc3c3d087739a72452e53a7e3b
7
+ data.tar.gz: '06093aba36c61e9a818afc9c82749416cee178345136cc3473877d5bc5354dd460189bfa02963d82354e38a4ce168b8a07412421c7b78f7c19cf2d826a8835e5'
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.2
4
+
5
+ - `permerror` rather than `pass` for an `rsa-sha1` signature, retired by RFC 8301 §3.1
6
+ - At most ten DKIM signatures are verified per message
7
+
3
8
  ## 0.3.1
4
9
 
5
10
  - `temperror` when no nameserver is usable, rather than a raise
data/lib/mailauth/arc.rb CHANGED
@@ -44,7 +44,7 @@ module MailAuth
44
44
  Dkim.parse_tags(value_of(field).to_s)
45
45
  end
46
46
 
47
- # sha1 is still legal for a DKIM signature and never was for ARC.
47
+ # RFC 8617 never registered sha1; DKIM's list matches only since retiring it.
48
48
  def self.signing_algorithm?(algorithm)
49
49
  SIGNING_ALGORITHMS.include?(signing_algorithm(algorithm)) && HASHES.include?(hash_algorithm(algorithm))
50
50
  end
data/lib/mailauth/dkim.rb CHANGED
@@ -17,7 +17,8 @@ module MailAuth
17
17
  # the algorithm is unsupported, or the key is unreadable.
18
18
  class Malformed < StandardError; end
19
19
 
20
- HASHES = { "sha1" => OpenSSL::Digest::SHA1, "sha256" => OpenSSL::Digest::SHA256 }.freeze
20
+ # RFC 8301 §3.1 retired rsa-sha1: a verifier must not consider one valid.
21
+ HASHES = { "sha256" => OpenSSL::Digest::SHA256 }.freeze
21
22
  SIGNING_ALGORITHMS = %w[ rsa ed25519 ].freeze
22
23
 
23
24
  # What OpenSSL calls a key, mapped to what a= calls it.
@@ -29,6 +30,10 @@ module MailAuth
29
30
  # RFC 6376 §3.2: ALPHA *ALNUMPUNC.
30
31
  TAG_NAME = /\A[a-zA-Z][a-zA-Z0-9_]*\z/n
31
32
 
33
+ # RFC 6376 §8.4. Each signature costs a lookup for a key its sender named,
34
+ # and headers are cheap to write, so only the first so many are answered.
35
+ MAXIMUM_SIGNATURES = 10
36
+
32
37
  # Shorter RSA keys are factorable cheaply enough to prove nothing.
33
38
  MINIMUM_RSA_BITS = 1024
34
39
 
@@ -37,10 +42,20 @@ module MailAuth
37
42
  ED25519_SPKI_PREFIX = [ "302a300506032b6570032100" ].pack("H*")
38
43
 
39
44
  def self.verify(message, resolver: Resolver.new, now: Time.now)
40
- signatures = message.fields_named("dkim-signature").map do |field|
45
+ fields = message.fields_named("dkim-signature")
46
+
47
+ signatures = fields.first(MAXIMUM_SIGNATURES).map do |field|
41
48
  Verification.new(message, field, resolver:, now:).result
42
49
  end
43
- signatures << Signature.new(status: Status::NONE, comment: "message not signed") if signatures.empty?
50
+
51
+ # The ones left over are reported rather than dropped: a verifier that
52
+ # quietly ignores a signature says a message carried fewer than it did.
53
+ if fields.empty?
54
+ signatures << Signature.new(status: Status::NONE, comment: "message not signed")
55
+ elsif fields.length > MAXIMUM_SIGNATURES
56
+ signatures << Signature.new(status: Status::PERMERROR,
57
+ comment: "#{fields.length - MAXIMUM_SIGNATURES} more signatures not evaluated")
58
+ end
44
59
 
45
60
  DkimResult.new(signatures:)
46
61
  end
@@ -1,3 +1,3 @@
1
1
  module MailAuth
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
data/mailauth.gemspec CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = [ "Simon Lev" ]
10
10
 
11
11
  spec.summary = "Email authentication for Ruby."
12
- spec.description = "Answers one question about a received message: is it really from who it says it's from?"
12
+ spec.description = "Answers one question about a received message: is it really from who it says it's from? Implements DKIM signing and verification, SPF, DMARC, and ARC."
13
13
 
14
14
  spec.homepage = "https://github.com/mailpiece/mailauth"
15
15
  spec.license = "MIT"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mailauth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Lev
@@ -52,7 +52,7 @@ dependencies:
52
52
  - !ruby/object:Gem::Version
53
53
  version: '0.2'
54
54
  description: 'Answers one question about a received message: is it really from who
55
- it says it''s from?'
55
+ it says it''s from? Implements DKIM signing and verification, SPF, DMARC, and ARC.'
56
56
  executables: []
57
57
  extensions: []
58
58
  extra_rdoc_files: []