dmarcator 1.4.1 → 1.6.0
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 +4 -4
- data/ChangeLog.md +13 -0
- data/README.md +15 -8
- data/lib/dmarcator/config.rb +6 -1
- data/lib/dmarcator/query.rb +61 -6
- data/lib/dmarcator/record.rb +2 -2
- data/lib/dmarcator/report/metadata.rb +6 -0
- data/lib/dmarcator/resolver/encrypted.rb +5 -1
- data/lib/dmarcator/version.rb +1 -1
- metadata +61 -58
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9f6316c6ee6743dd6e2e1396726525bef87cdfbe95985c63b44b4da35d5b2d3e
|
|
4
|
+
data.tar.gz: d0d1e9f677dc31b7ccbedf45d003805e9ecad3ad291ea98d9f058d8f7f9a2b1a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ad2f9c279435732be3148c6adf2e227c33df6bb1589e918f6567e606936afb992fb0d93ac5dc88d54b0d324bbdb1c4706d867b5470cc1d9d9577b33ddadb21a0
|
|
7
|
+
data.tar.gz: 9ef713270c87bb56cebb484eff98d7d0098e6bab63fe3b937177b154cd67ec9cae8ce24ebb185b5eccb1579a6e64ad0b34270429d0b6c10efcf0b37785cecf56
|
data/ChangeLog.md
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
### 1.6.0 / 2026-11-21
|
|
2
|
+
|
|
3
|
+
* Reject an injected `Resolv::DNS` that was not constructed with `raise_timeout_errors: true`. By default `Resolv` treats a complete timeout as an empty answer, so a failed lookup was indistinguishable from a name with no records, contradicting the documented fail-closed guarantee. Construct the resolver with `Resolv::DNS.new(raise_timeout_errors: true)`, or use `DMARCator::Resolver::Plain`. This is a behaviour change for callers that inject a bare `Resolv::DNS`.
|
|
4
|
+
* `Record#to_s` preserves the optional `!size` and unit of `rua`/`ruf` URIs. `Array#join` preferred the delegated `to_str`, which returned the bare `mailto:` URI, so serializing a record silently dropped its report-size limits.
|
|
5
|
+
* `Report#metadata` returns an empty `Report::Metadata` when `<report_metadata>` is absent instead of raising `NoMethodError`. `report_metadata` is required by the DMARC schema, but the XML guard only enforces the `<feedback>` root, so a report could omit it and crash the accessor with an error outside `DMARCator::Error`.
|
|
6
|
+
* DNS transaction IDs are drawn from `SecureRandom` rather than `Random`, removing a predictable ID from the plaintext TCP transport.
|
|
7
|
+
|
|
8
|
+
No public API changes.
|
|
9
|
+
|
|
10
|
+
### 1.5.0 / 2026-11-19
|
|
11
|
+
|
|
12
|
+
* Require Ruby >= 3.3.14. The supported minima per series are 3.3.14, 3.4.13, and 4.0.10; CI now tests each minimum instead of 3.3.13 plus latest 4.0.
|
|
13
|
+
|
|
1
14
|
### 1.4.1 / 2026-11-02
|
|
2
15
|
|
|
3
16
|
* Update `nokogiri` dependency to `>= 1.19.5`, patches CVEs in nokogiri upstream.
|
data/README.md
CHANGED
|
@@ -149,7 +149,11 @@ end
|
|
|
149
149
|
```
|
|
150
150
|
|
|
151
151
|
All of these accept an injected resolver, and an injected resolver keeps its
|
|
152
|
-
own configuration (timeouts are only applied to resolvers the library builds)
|
|
152
|
+
own configuration (timeouts are only applied to resolvers the library builds).
|
|
153
|
+
A `Resolv::DNS` must be constructed with `raise_timeout_errors: true`: without
|
|
154
|
+
it, `Resolv` treats a complete timeout as an empty answer, and the lookup would
|
|
155
|
+
be indistinguishable from one for a name with no records. The lookup methods
|
|
156
|
+
reject such a resolver with `ArgumentError` rather than report a false negative.
|
|
153
157
|
|
|
154
158
|
```ruby
|
|
155
159
|
resolver = DMARCator::Resolver::DoH.new(url: "https://dns.example/dns-query")
|
|
@@ -219,7 +223,7 @@ configure a factory instead:
|
|
|
219
223
|
|
|
220
224
|
```ruby
|
|
221
225
|
DMARCator.configure do |config|
|
|
222
|
-
config.resolver = -> { Resolv::DNS.new }
|
|
226
|
+
config.resolver = -> { Resolv::DNS.new(raise_timeout_errors: true) }
|
|
223
227
|
end
|
|
224
228
|
```
|
|
225
229
|
|
|
@@ -292,9 +296,11 @@ failures raise `DMARCator::ResolutionError`.
|
|
|
292
296
|
|
|
293
297
|
Encrypted transports fail closed: a transport failure raises
|
|
294
298
|
`DMARCator::ResolutionError` instead of being reported as a domain without a
|
|
295
|
-
DMARC record. This applies to every transport, including
|
|
296
|
-
`Resolv`
|
|
297
|
-
|
|
299
|
+
DMARC record. This applies to every transport the library builds, including
|
|
300
|
+
plaintext. An injected `Resolv::DNS` is the one exception: by default it treats
|
|
301
|
+
a complete timeout as an empty answer, so construct it with
|
|
302
|
+
`raise_timeout_errors: true` — the lookup methods reject one that does not,
|
|
303
|
+
rather than mistake a failed lookup for an absent record.
|
|
298
304
|
Plaintext remains the default because forcing a public resolver breaks private
|
|
299
305
|
and split-horizon zones, and some networks block port 853 or public resolvers.
|
|
300
306
|
|
|
@@ -332,8 +338,9 @@ removed in the next major release.
|
|
|
332
338
|
|
|
333
339
|
### Ruby support
|
|
334
340
|
|
|
335
|
-
The minimum is Ruby 3.3.
|
|
336
|
-
|
|
341
|
+
The minimum is Ruby 3.3.14, which includes the regular expression fixes the
|
|
342
|
+
library requires. The supported minima per series are 3.3.14, 3.4.13, and
|
|
343
|
+
4.0.10. Dropping support for a Ruby series is
|
|
337
344
|
the one documented exception to the no-breaking-changes promise: it is announced
|
|
338
345
|
in a minor release and removed in the next major.
|
|
339
346
|
|
|
@@ -389,7 +396,7 @@ for the reporting policy and scope.
|
|
|
389
396
|
|
|
390
397
|
## Requirements
|
|
391
398
|
|
|
392
|
-
* [Ruby] >= 3.3.
|
|
399
|
+
* [Ruby] >= 3.3.14
|
|
393
400
|
* [nokogiri] >= 1.10
|
|
394
401
|
|
|
395
402
|
## Testing
|
data/lib/dmarcator/config.rb
CHANGED
|
@@ -72,6 +72,11 @@ module DMARCator
|
|
|
72
72
|
# resolver object is shared by every thread, and `Resolv::DNS` does not
|
|
73
73
|
# serialise concurrent lookups.
|
|
74
74
|
#
|
|
75
|
+
# A `Resolv::DNS` must be constructed with `raise_timeout_errors: true`;
|
|
76
|
+
# otherwise it reports a timeout as an empty answer, and a lookup will
|
|
77
|
+
# reject it with `ArgumentError` rather than mistake a failure for an
|
|
78
|
+
# absent record.
|
|
79
|
+
#
|
|
75
80
|
# @return [Object, #call, nil]
|
|
76
81
|
#
|
|
77
82
|
attr_accessor :resolver
|
|
@@ -194,7 +199,7 @@ module DMARCator
|
|
|
194
199
|
# Configures process-wide defaults.
|
|
195
200
|
#
|
|
196
201
|
# DMARCator.configure do |config|
|
|
197
|
-
# config.resolver = -> { Resolv::DNS.new }
|
|
202
|
+
# config.resolver = -> { Resolv::DNS.new(raise_timeout_errors: true) }
|
|
198
203
|
# end
|
|
199
204
|
#
|
|
200
205
|
# When set, a configured resolver takes precedence over `DMARCATOR_DNS` and
|
data/lib/dmarcator/query.rb
CHANGED
|
@@ -174,7 +174,8 @@ module DMARCator
|
|
|
174
174
|
# blocked or degraded resolver cannot be mistaken for an absent record.
|
|
175
175
|
#
|
|
176
176
|
# @raise [ArgumentError]
|
|
177
|
-
# The name is not a syntactically valid DNS name
|
|
177
|
+
# The name is not a syntactically valid DNS name, or the injected
|
|
178
|
+
# resolver would report a timeout as an absent record.
|
|
178
179
|
#
|
|
179
180
|
# @note Names must be ASCII: pass punycode (A-labels) rather than Unicode.
|
|
180
181
|
#
|
|
@@ -207,7 +208,8 @@ module DMARCator
|
|
|
207
208
|
# The lookup failed. A failure is never reported as an empty result.
|
|
208
209
|
#
|
|
209
210
|
# @raise [ArgumentError]
|
|
210
|
-
# The name is not a syntactically valid DNS name
|
|
211
|
+
# The name is not a syntactically valid DNS name, or the injected
|
|
212
|
+
# resolver would report a timeout as an absent record.
|
|
211
213
|
#
|
|
212
214
|
# @note Names must be ASCII: pass punycode (A-labels) rather than Unicode.
|
|
213
215
|
#
|
|
@@ -238,7 +240,8 @@ module DMARCator
|
|
|
238
240
|
# The lookup failed.
|
|
239
241
|
#
|
|
240
242
|
# @raise [ArgumentError]
|
|
241
|
-
# The domain is not a syntactically valid DNS name
|
|
243
|
+
# The domain is not a syntactically valid DNS name, or the injected
|
|
244
|
+
# resolver would report a timeout as an absent record.
|
|
242
245
|
#
|
|
243
246
|
# @since 0.8.0
|
|
244
247
|
#
|
|
@@ -272,9 +275,11 @@ module DMARCator
|
|
|
272
275
|
# @api private
|
|
273
276
|
#
|
|
274
277
|
def self.lookup_txt(name, resolver:)
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
#
|
|
278
|
+
ensure_fail_closed!(resolver)
|
|
279
|
+
|
|
280
|
+
# With a fail-closed resolver, Resolv returns an empty result for NXDOMAIN
|
|
281
|
+
# and raises for timeouts and other failures, so any exception here is a
|
|
282
|
+
# transport failure, not an absent record.
|
|
278
283
|
begin
|
|
279
284
|
records = resolver.getresources(name, Resolv::DNS::Resource::IN::TXT)
|
|
280
285
|
rescue Resolv::ResolvError => error
|
|
@@ -284,6 +289,56 @@ module DMARCator
|
|
|
284
289
|
records
|
|
285
290
|
end
|
|
286
291
|
private_class_method :lookup_txt
|
|
292
|
+
|
|
293
|
+
#
|
|
294
|
+
# Determines whether a resolver reports a timeout instead of returning an
|
|
295
|
+
# empty answer.
|
|
296
|
+
#
|
|
297
|
+
# `Resolv::DNS` treats a complete timeout as an empty answer unless it was
|
|
298
|
+
# constructed with `raise_timeout_errors: true`. The flag is only settable
|
|
299
|
+
# through the constructor and `Resolv` exposes no reader for it, so it is
|
|
300
|
+
# read from the retained configuration.
|
|
301
|
+
#
|
|
302
|
+
# @param [Object] resolver
|
|
303
|
+
#
|
|
304
|
+
# @return [Boolean]
|
|
305
|
+
#
|
|
306
|
+
# @api private
|
|
307
|
+
#
|
|
308
|
+
def self.resolv_fails_closed?(resolver)
|
|
309
|
+
return true unless resolver.is_a?(Resolv::DNS)
|
|
310
|
+
|
|
311
|
+
config = resolver.instance_variable_get(:@config)
|
|
312
|
+
return false unless config
|
|
313
|
+
|
|
314
|
+
info = config.instance_variable_get(:@config_info)
|
|
315
|
+
return false unless info.is_a?(Hash)
|
|
316
|
+
|
|
317
|
+
!!info[:raise_timeout_errors]
|
|
318
|
+
end
|
|
319
|
+
private_class_method :resolv_fails_closed?
|
|
320
|
+
|
|
321
|
+
#
|
|
322
|
+
# Rejects a resolver that would report a failed lookup as an absent record.
|
|
323
|
+
#
|
|
324
|
+
# @param [Object] resolver
|
|
325
|
+
#
|
|
326
|
+
# @raise [ArgumentError]
|
|
327
|
+
# The resolver is a `Resolv::DNS` that does not raise on timeout.
|
|
328
|
+
#
|
|
329
|
+
# @api private
|
|
330
|
+
#
|
|
331
|
+
def self.ensure_fail_closed!(resolver)
|
|
332
|
+
return if resolv_fails_closed?(resolver)
|
|
333
|
+
|
|
334
|
+
raise ArgumentError,
|
|
335
|
+
'a Resolv::DNS resolver swallows timeout errors unless constructed ' \
|
|
336
|
+
'with raise_timeout_errors: true, so a failed lookup cannot be ' \
|
|
337
|
+
'distinguished from a name with no records; use ' \
|
|
338
|
+
'Resolv::DNS.new(raise_timeout_errors: true) or ' \
|
|
339
|
+
'DMARCator::Resolver::Plain'
|
|
340
|
+
end
|
|
341
|
+
private_class_method :ensure_fail_closed!
|
|
287
342
|
end
|
|
288
343
|
|
|
289
344
|
if DMARCator.vulnerable_resolv?
|
data/lib/dmarcator/record.rb
CHANGED
|
@@ -353,8 +353,8 @@ module DMARCator
|
|
|
353
353
|
tags << "v=#{@v}" if @v
|
|
354
354
|
tags << "p=#{@p}" if @p
|
|
355
355
|
tags << "sp=#{@sp}" if @sp
|
|
356
|
-
tags << "rua=#{@rua.join(',')}" if @rua
|
|
357
|
-
tags << "ruf=#{@ruf.join(',')}" if @ruf
|
|
356
|
+
tags << "rua=#{@rua.map(&:to_s).join(',')}" if @rua
|
|
357
|
+
tags << "ruf=#{@ruf.map(&:to_s).join(',')}" if @ruf
|
|
358
358
|
tags << "adkim=#{@adkim}" if @adkim
|
|
359
359
|
tags << "aspf=#{@aspf}" if @aspf
|
|
360
360
|
tags << "ri=#{@ri}" if @ri
|
|
@@ -38,6 +38,12 @@ module DMARCator
|
|
|
38
38
|
|
|
39
39
|
metadata = node.at_xpath('feedback/report_metadata')
|
|
40
40
|
|
|
41
|
+
# `report_metadata` is required by the DMARC schema, but the XML guard
|
|
42
|
+
# only enforces the `<feedback>` root, so an attacker-supplied report can
|
|
43
|
+
# omit it. Treat it like a missing `policy_published` rather than
|
|
44
|
+
# raising NoMethodError out of a public accessor.
|
|
45
|
+
return unless metadata
|
|
46
|
+
|
|
41
47
|
metadata.element_children.each do |element|
|
|
42
48
|
case element.name
|
|
43
49
|
when 'org_name'
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'resolv'
|
|
4
|
+
require 'securerandom'
|
|
4
5
|
|
|
5
6
|
require_relative '../exceptions'
|
|
6
7
|
|
|
@@ -51,7 +52,10 @@ module DMARCator
|
|
|
51
52
|
end
|
|
52
53
|
|
|
53
54
|
def fetch(name, type, depth)
|
|
54
|
-
|
|
55
|
+
# A predictable transaction ID would let an off-path attacker guess the
|
|
56
|
+
# query before it is answered. Over TLS this is already unreachable, but
|
|
57
|
+
# the plaintext TCP transport shares this code path.
|
|
58
|
+
id = SecureRandom.random_number(0x10000)
|
|
55
59
|
message = decode_response(exchange(build_query(id, name, type)), id, name, type)
|
|
56
60
|
|
|
57
61
|
case message.rcode
|
data/lib/dmarcator/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,84 +1,87 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dmarcator
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
|
-
- Noah Berman
|
|
7
|
+
- Noah Berman
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
10
|
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
|
-
- !ruby/object:Gem::Dependency
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: nokogiri
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
-
|
|
17
|
+
- ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: 1.19.5
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
-
|
|
25
|
+
- ">="
|
|
26
|
+
- !ruby/object:Gem::Version
|
|
27
|
+
version: 1.19.5
|
|
28
|
+
description: "A hardened DMARC record parser and query client, forked from the Trail of Bits 'dmarc' gem."
|
|
28
29
|
email:
|
|
29
|
-
- noah@noahberman.org
|
|
30
|
+
- noah@noahberman.org
|
|
30
31
|
executables: []
|
|
31
32
|
extensions: []
|
|
32
33
|
extra_rdoc_files: []
|
|
33
34
|
files:
|
|
34
|
-
- ChangeLog.md
|
|
35
|
-
- LICENSE.txt
|
|
36
|
-
- README.md
|
|
37
|
-
- lib/dmarcator.rb
|
|
38
|
-
- lib/dmarcator/config.rb
|
|
39
|
-
- lib/dmarcator/exceptions.rb
|
|
40
|
-
- lib/dmarcator/internal/parser.rb
|
|
41
|
-
- lib/dmarcator/internal/xml_guard.rb
|
|
42
|
-
- lib/dmarcator/internal/xml_helper.rb
|
|
43
|
-
- lib/dmarcator/query.rb
|
|
44
|
-
- lib/dmarcator/record.rb
|
|
45
|
-
- lib/dmarcator/report.rb
|
|
46
|
-
- lib/dmarcator/report/auth_result.rb
|
|
47
|
-
- lib/dmarcator/report/metadata.rb
|
|
48
|
-
- lib/dmarcator/report/policy.rb
|
|
49
|
-
- lib/dmarcator/report/reason.rb
|
|
50
|
-
- lib/dmarcator/report/row.rb
|
|
51
|
-
- lib/dmarcator/resolver.rb
|
|
52
|
-
- lib/dmarcator/resolver/doh.rb
|
|
53
|
-
- lib/dmarcator/resolver/dot.rb
|
|
54
|
-
- lib/dmarcator/resolver/encrypted.rb
|
|
55
|
-
- lib/dmarcator/resolver/plain.rb
|
|
56
|
-
- lib/dmarcator/uri.rb
|
|
57
|
-
- lib/dmarcator/version.rb
|
|
58
|
-
homepage: https://github.com/bermannoah/dmarcator
|
|
35
|
+
- ChangeLog.md
|
|
36
|
+
- LICENSE.txt
|
|
37
|
+
- README.md
|
|
38
|
+
- lib/dmarcator.rb
|
|
39
|
+
- lib/dmarcator/config.rb
|
|
40
|
+
- lib/dmarcator/exceptions.rb
|
|
41
|
+
- lib/dmarcator/internal/parser.rb
|
|
42
|
+
- lib/dmarcator/internal/xml_guard.rb
|
|
43
|
+
- lib/dmarcator/internal/xml_helper.rb
|
|
44
|
+
- lib/dmarcator/query.rb
|
|
45
|
+
- lib/dmarcator/record.rb
|
|
46
|
+
- lib/dmarcator/report.rb
|
|
47
|
+
- lib/dmarcator/report/auth_result.rb
|
|
48
|
+
- lib/dmarcator/report/metadata.rb
|
|
49
|
+
- lib/dmarcator/report/policy.rb
|
|
50
|
+
- lib/dmarcator/report/reason.rb
|
|
51
|
+
- lib/dmarcator/report/row.rb
|
|
52
|
+
- lib/dmarcator/resolver.rb
|
|
53
|
+
- lib/dmarcator/resolver/doh.rb
|
|
54
|
+
- lib/dmarcator/resolver/dot.rb
|
|
55
|
+
- lib/dmarcator/resolver/encrypted.rb
|
|
56
|
+
- lib/dmarcator/resolver/plain.rb
|
|
57
|
+
- lib/dmarcator/uri.rb
|
|
58
|
+
- lib/dmarcator/version.rb
|
|
59
|
+
homepage: "https://github.com/bermannoah/dmarcator"
|
|
59
60
|
licenses:
|
|
60
|
-
- MIT
|
|
61
|
+
- MIT
|
|
61
62
|
metadata:
|
|
62
|
-
source_code_uri: https://github.com/bermannoah/dmarcator
|
|
63
|
-
bug_tracker_uri: https://github.com/bermannoah/dmarcator/issues
|
|
64
|
-
changelog_uri: https://github.com/bermannoah/dmarcator/blob/main/ChangeLog.md
|
|
65
|
-
documentation_uri: https://rubydoc.info/gems/dmarcator
|
|
66
|
-
rubygems_mfa_required:
|
|
63
|
+
source_code_uri: "https://github.com/bermannoah/dmarcator"
|
|
64
|
+
bug_tracker_uri: "https://github.com/bermannoah/dmarcator/issues"
|
|
65
|
+
changelog_uri: "https://github.com/bermannoah/dmarcator/blob/main/ChangeLog.md"
|
|
66
|
+
documentation_uri: "https://rubydoc.info/gems/dmarcator"
|
|
67
|
+
rubygems_mfa_required: "true"
|
|
67
68
|
rdoc_options: []
|
|
68
69
|
require_paths:
|
|
69
|
-
- lib
|
|
70
|
+
- lib
|
|
70
71
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
71
72
|
requirements:
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
-
|
|
74
|
+
- ">="
|
|
75
|
+
- !ruby/object:Gem::Version
|
|
76
|
+
version: 3.3.14
|
|
75
77
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
78
|
requirements:
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
79
|
+
-
|
|
80
|
+
- ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: "0"
|
|
80
83
|
requirements: []
|
|
81
|
-
rubygems_version: 4.0
|
|
84
|
+
rubygems_version: 4.1.0
|
|
82
85
|
specification_version: 4
|
|
83
86
|
summary: DMARC record parser and query client
|
|
84
87
|
test_files: []
|