Skip to content

Commit 0488c3d

Browse files
committed
stir_shaken DIV: Bump freshness margin from 1s to 60s
1 parent 74c3ff0 commit 0488c3d

4 files changed

Lines changed: 22 additions & 16 deletions

File tree

‎modules/stir_shaken/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ SHAKEN and earlier DIV tokens. The outermost token uses
110110
token, this parameter has no effect.
111111

112112
When omitted, the default is `10800` (three hours), or
113-
`verify_date_freshness + 1` if that is larger. An explicit value must exceed
113+
`verify_date_freshness + 60` if that is larger. An explicit value must exceed
114114
`verify_date_freshness`, or be `-1` to skip inner freshness checking.
115115

116116
The `inner_freshness` argument to `stir_shaken_verify_chain()` overrides this

‎modules/stir_shaken/test/README.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,6 @@ results for A/B/C, bad signature, stale outermost, broken chain, and absent
5858
Identity. Tests check its resulting `verstat` on the serialized request.
5959

6060
Freshness initialization tests cover the normal three-hour inner default,
61-
automatic adjustment when the outer window grows, preservation of explicit
62-
inner settings and `-1`, invalid explicit limits, and integer overflow bounds.
61+
automatic adjustment to retain a 60-second margin as the outer window grows,
62+
preservation of explicit inner settings and `-1`, invalid explicit limits, and
63+
integer overflow bounds.

‎modules/stir_shaken/test/test_vs.c‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,23 @@ static void test_freshness_defaults(void)
2222
const char *name;
2323
} cases[] = {
2424
{60,10800,0,0,60,10800,"ordinary outer window retains three-hour default"},
25-
{10799,10800,0,0,10799,10800,"default already exceeds outer window"},
26-
{10800,10800,0,0,10800,10801,"default grows when outer reaches three hours"},
27-
{28400,10800,0,0,28400,28401,"untouched default follows enlarged outer window"},
25+
{10740,10800,0,0,10740,10800,"default already has a full minute of margin"},
26+
{10741,10800,0,0,10741,10801,"default grows when margin falls below one minute"},
27+
{10799,10800,0,0,10799,10859,"default grows even when it already exceeds outer window"},
28+
{10799,10800,1,0,10799,10800,"explicit inner window need not adopt the default margin"},
29+
{10800,10800,0,0,10800,10860,"default grows when outer reaches three hours"},
30+
{28400,10800,0,0,28400,28460,"untouched default follows enlarged outer window"},
2831
{28400,10800,1,-1,28400,10800,"explicit three-hour limit is not silently increased"},
2932
{28400,40000,1,0,28400,40000,"explicit larger inner limit is preserved"},
3033
{28400,-1,1,0,28400,-1,"explicit inner bypass is preserved"},
3134
{-1,10800,0,-1,-1,10800,"negative outer window remains invalid"},
3235
{60,0,1,-1,60,0,"explicit zero inner window remains invalid"},
3336
{28400,28400,1,-1,28400,28400,"explicit equal inner window remains invalid"},
34-
{INT_MAX-1,10800,0,0,INT_MAX-1,INT_MAX,"largest representable inherited limit"},
35-
{INT_MAX,10800,0,0,INT_MAX-1,INT_MAX,"maximal outer window leaves room for inner default"},
36-
{INT_MAX,-1,1,0,INT_MAX-1,-1,"clamping the outer window preserves explicit inner bypass"},
37-
{INT_MAX,INT_MAX,1,0,INT_MAX-1,INT_MAX,"clamping permits an explicit maximal inner window"}
37+
{INT_MAX-60,10800,0,0,INT_MAX-60,INT_MAX,"largest outer window with a full minute of margin"},
38+
{INT_MAX-59,10800,0,0,INT_MAX-60,INT_MAX,"clamping starts when a full minute would overflow"},
39+
{INT_MAX,10800,0,0,INT_MAX-60,INT_MAX,"maximal outer window leaves room for inner default"},
40+
{INT_MAX,-1,1,0,INT_MAX-60,-1,"clamping the outer window preserves explicit inner bypass"},
41+
{INT_MAX,INT_MAX,1,0,INT_MAX-60,INT_MAX,"clamping permits an explicit maximal inner window"}
3842
};
3943
int i, outer, inner, rc;
4044
for (i = 0; i < sizeof(cases)/sizeof(cases[0]); i++) {

‎modules/stir_shaken/verify.c‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
#include "../../parser/parse_uri.h"
1010

1111
/* The default earlier-token window is three hours, increased at startup if
12-
* needed to exceed the normal outermost window. Per-call -1 disables only
13-
* earlier-token age checks. */
12+
* needed to leave 60 seconds above the normal outermost window. Per-call -1
13+
* disables only earlier-token age checks. */
14+
#define INNER_FRESHNESS_MARGIN 60
1415
int verify_date_div_freshness = 10800;
1516
static int snapshot_ctx = -1;
1617

@@ -46,13 +47,13 @@ static int resolve_freshness(int *outer, int inner_configured, int *inner)
4647
LM_ERR("verify_date_freshness must not disable outermost freshness\n");
4748
return -1;
4849
}
49-
if (*outer >= INT_MAX) {
50-
*outer = INT_MAX - 1;
50+
if (*outer > INT_MAX - INNER_FRESHNESS_MARGIN) {
51+
*outer = INT_MAX - INNER_FRESHNESS_MARGIN;
5152
LM_WARN("reducing verify_date_freshness to %d to leave room for verify_date_div_freshness\n",
5253
*outer);
5354
}
54-
if (!inner_configured && *inner <= *outer) {
55-
*inner = *outer + 1;
55+
if (!inner_configured && *inner < *outer + INNER_FRESHNESS_MARGIN) {
56+
*inner = *outer + INNER_FRESHNESS_MARGIN;
5657
LM_INFO("using default verify_date_div_freshness=%d to exceed verify_date_freshness=%d\n",
5758
*inner, *outer);
5859
}

0 commit comments

Comments
 (0)