Why the gate needs its own test
A USB or HID scanner is a keyboard to the computer. Everything it "types" reaches the system as text, and someone can encode any text in a QR code and hold it to the reader. That is why the acceptance question is not "does the gate read good codes", but "what does it do with bad ones".
In InnerWeb the scanner is treated only as a keyboard: the typed string is a sequence of characters to be classified by a regular expression, never an address to open, HTML to display or code to execute. The test below lets the administrator check this on their own installation, without access to the source code.
Preparing the test station
The test is run at the acceptance station, in the presence of a supplier's representative, on a test account or in a window without staff traffic. Prepare a QR code generator that encodes any text, and a scanner identical to the one that will be at the gate. Record the time, the typed string and the system's response.
Before the test, define the expected behaviour: no open access, no execution of the content, a uniform error message and an entry in the attempt history. A response that differs from this should be recorded as a deviation.
Lengths: badge token and gate limit
The set of strings to pass through the scanner
The set should cover several classes of threats. For each one generate a separate QR code and scan it at the gate. The InnerWeb gate tests pass a set of malicious strings: a javascript: script, a script tag, a path leaving the directory, a string resembling an SQL injection, and a fabricated 64-character token on a foreign domain. None of them opens access.
The own test is worth extending with a string much longer than a standard token and with a string containing control characters, because these are the classes that usually break naive parsers.
- An address with the javascript: script protocol.
- A script tag in the content.
- A path leaving the directory.
- A string resembling an SQL injection.
- A fabricated 64-character token on a foreign domain.
- A string longer than 512 characters.
What the gate should do with each string
On the server side the value from the gate is checked again: the browser sends only the raw string, and its own recognition result is not taken into account. This matters, because an attacker can modify what the browser does, but cannot change the check on the server side.
The gate rejects a string longer than 512 characters before it starts to recognise it. The lookup of badges and cards in the database is done exclusively with parameterised queries, so a string resembling SQL is treated as data, not as a command. A revoked, an unknown and an invented code give the same message "unknown code" (404), without returning the scanned string.
Why the response does not return the string
Returning the scanned string in an error message opens a path to injecting content onto the guard's screen. A message that does not quote the input removes this class of problems. During the test check that the content of the message is fixed and does not contain a fragment of the string.
Two scans in a short interval
The server applies an anti-duplicate window, and the browser additionally discards an identical string within a window of a few seconds, so a slower response does not overwrite a faster one on the screen. For the test scan the same code twice in quick succession and check that the history entry is not duplicated.
How to document the test result
The test protocol should contain the list of strings, the time of each scan, the gate's response and an assessment of compliance with the expectation. For each class record one of three outcomes: no access and a uniform message, a deviation to be explained, or a critical error blocking acceptance.
The result supports the proof of acceptance and may be attached to the plant's information security documentation. It does not replace a penetration test, but at installation acceptance it shows that the basic classes of strings that may come from a scanner have been tested.
Checklist
Video
Frequently asked questions
Can the test harm the production system?
Run it at the acceptance station or in a window without traffic. The strings are plain text to the system, but the attempts go into the history, so mark them as test entries.
Can the browser decide by itself that a code is correct?
No. The browser sends only the raw string, and the server checks it again and does not take into account the recognition result from the browser.
Can the 512-character limit be changed?
It is a constant of the gate described in the feature description. For ordinary tokens of 64 characters it leaves a large margin, and it rejects strings that cannot be a real code.
Sources
Let's run the gate acceptance test together
We will prepare a set of test codes and a protocol that can be attached to the installation acceptance documentation.
Let's talk