altcha 3.0.0 → 3.1.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 +10 -0
- data/Gemfile.lock +1 -1
- data/lib/altcha/v1.rb +9 -2
- data/lib/altcha/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 849b1a649c7c8fc56f3a0c0ceedff029c6632e3f786706bc3de683f2ee1870bb
|
|
4
|
+
data.tar.gz: 969fb0744d694a25ebcea42a7e9ad9205d9d860c9d6c464d3158e768276e46bc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ba85431ed8e3808efe6cceba2b86cd5ecbaf4aa1f1cfeb83f53ab80e3344a8dc7c469f61a610360afd546b64e4ca4601ef6b63c20d1dc7f791a581f2917e01f0
|
|
7
|
+
data.tar.gz: f5123c5a9ecac589791fd8df2eb9cf347538db36051a285924235a4e4116ce2ec41d6f1e8d096f45664a9f8e55b232bcdf2c47ba8cbafc910af20fe05f3693ad
|
data/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
3
3
|
All notable changes to this project are documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
5
5
|
|
|
6
|
+
## [3.1.0] - 2026-11-21
|
|
7
|
+
|
|
8
|
+
### Security
|
|
9
|
+
|
|
10
|
+
- `Altcha::V1.verify_solution` returns `false` when `number` is not an `Integer`. Before, a String `number` could carry the tail of the signed salt across the `&` delimiter: the challenge and signature still matched, but the expiry check and `extract_params` only saw the shortened salt. This hid trailing signed params when `check_expires` was `false`, or when they came after `expires` in a custom `salt`. Together with the fix below, it would also have let an expired challenge verify. `Altcha::V1.create_challenge` raises `ArgumentError` for a `number` that is not an `Integer`.
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- `Altcha::V1.verify_solution` with `check_expires = true` verifies a challenge whose salt has a query but no `expires`, such as one created with `params` and without `expires`. Before, a missing `expires` was read as `0` and the challenge was rejected as expired. A present `expires` that is not a number is still rejected.
|
|
15
|
+
|
|
6
16
|
## [3.0.0] - 2026-10-04
|
|
7
17
|
|
|
8
18
|
Brings `Altcha::V2` in line with the reference JS implementation: challenges, solutions and signatures now interoperate in both directions.
|
data/Gemfile.lock
CHANGED
data/lib/altcha/v1.rb
CHANGED
|
@@ -205,6 +205,10 @@ module Altcha
|
|
|
205
205
|
salt += salt.end_with?('&') ? '' : '&'
|
|
206
206
|
|
|
207
207
|
number = options.number || random_int(max_number)
|
|
208
|
+
# A non-Integer number (e.g. a String containing '&') could carry part of
|
|
209
|
+
# the signed salt, moving the salt/number boundary past the delimiter.
|
|
210
|
+
raise ArgumentError, "number must be an Integer, got #{number.class}" unless number.is_a?(Integer)
|
|
211
|
+
|
|
208
212
|
challenge = hash_hex(algorithm, "#{salt}#{number}")
|
|
209
213
|
signature = hmac_hex(algorithm, challenge, options.hmac_key)
|
|
210
214
|
|
|
@@ -237,9 +241,12 @@ module Altcha
|
|
|
237
241
|
return false if value.nil? || value.to_s.strip.empty?
|
|
238
242
|
end
|
|
239
243
|
|
|
244
|
+
# Reject before hashing; see create_challenge.
|
|
245
|
+
return false unless payload.number.is_a?(Integer)
|
|
246
|
+
|
|
240
247
|
if check_expires && payload.salt.include?('?')
|
|
241
|
-
expires = URI.decode_www_form(payload.salt.split('?').last).to_h['expires']
|
|
242
|
-
return false if expires && Time.now.to_i > expires
|
|
248
|
+
expires = URI.decode_www_form(payload.salt.split('?').last).to_h['expires']
|
|
249
|
+
return false if expires && Time.now.to_i > expires.to_i
|
|
243
250
|
end
|
|
244
251
|
|
|
245
252
|
expected = create_challenge(
|
data/lib/altcha/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: altcha
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.
|
|
4
|
+
version: 3.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Daniel Regeci
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-11-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: base64
|