Validate AfosId/WmoIdentifier character classes before IEM SPS URLs#13
Merged
Conversation
MapService.BuildIemSpsUrl/VerifyIemSpsAsync only length-checked
alert.AfosId and alert.WmoIdentifier before embedding substrings of
them into a colon-delimited IEM autoplot #217 URL. The VTEC fields
used by the sibling BuildIemUrl/ResolveIemPhenomenaAsync methods are
safe because NwsAlertService.VtecPattern's regex already constrains
their character classes before they reach MapService -- AfosId/
WmoIdentifier had no equivalent parser-side validation.
Added AfosSpsPattern (^SPS[A-Z]{3}$) and Wmo6Pattern (^[A-Z0-9]{6}$),
checked before building the URL; falls back to Mapbox on failure,
identical to the existing length-check failure path. Also escapes the
wfo query parameter in VerifyIemSpsAsync's GET request as further
defense in depth.
Verified the patterns against real example values (SPSMPX, SPSOUN,
WWUS83) and injection-shaped strings (colons, slashes, wrong length,
wrong case) in an isolated test before landing -- all matched/rejected
as expected.
MikeWills
force-pushed
the
security/validate-iem-sps-fields
branch
from
July 8, 2026 19:23
0749e1c to
2dc05c8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the one real finding (Low severity) from the earlier full codebase security review.
MapService.BuildIemSpsUrl/VerifyIemSpsAsynconly length-checkedalert.AfosId/alert.WmoIdentifierbefore embedding substrings of them into a colon-delimited IEM autoplot #217 URL (pid:{pid}::segnum:0::...).BuildIemUrl/ResolveIemPhenomenaAsync: their VTEC-derived inputs are already constrained to safe character classes ([A-Z]{4}/[A-Z]{2}/[A-Z]/\d{4}) byNwsAlertService.VtecPattern's regex before ever reachingMapService.AfosId/WmoIdentifierhad no equivalent validation.AfosSpsPattern(^SPS[A-Z]{3}$) andWmo6Pattern(^[A-Z0-9]{6}$), checked before building the URL. On failure, falls back to Mapbox — identical to the existing length-check failure path, no new failure mode.wfoquery parameter inVerifyIemSpsAsync's GET request withUri.EscapeDataStringas further defense in depth.SPSMPX,SPSOUN,WWUS83) and injection-shaped strings (colons, slashes, wrong length/case) in an isolated test before landing — all matched/rejected as expected.Risk: since real NWS
AfosId/WmoIdentifiervalues already conform to these patterns, this should be a no-op for all legitimate SPS alerts — exploitability of the original gap was already low (NWS's own trusted feed), this is defense in depth.Test plan
dotnet buildpasses (done, 0 warnings/errors)