Item 4: repeated submits Repeated submits of forms
occur frequently, especially where connections are slow. Want to bet
you've done it yourself: click, wait 4 or 5 seconds, click, click,
click. If the receiving script isn't prepared for this, things can
start to go bad fast; multiple submits can even bring down a server
in some instances.
To prevent multiple submits, use some submit count method. This is
best done in JavaScript at the client machine so that the server
doesn't have to deal with such problems. A favorite method of ours is
to replace the message on the submit button when the form is submitted
to something like, "Processing, Please Wait". This message is then
used to disable any subsequent submits.
Item 5, malicious code It's little known, except to
certain hackers, that executable code can be introduced to a server
through form fields. This is potentially a very nasty vulnerability.
Prevent this from happening by declaring a character type in the head
of the form document and use JavaScript before submitting the form to
check entries for unwanted characters. For instance a back slash (\)
entry might be indicative of an attack.
FORM AND SITE DESIGN
At this point it should be evident that forms of themselves
cannot be used as a trusted source of information, hidden form
fields and SSL not withstanding.
Credit card information gathering forms especially should never,
ever be submitted directly to a gateway for card processing. Such
a form would have to have the merchant ID numbers in it exposing
vital information to anyone wanting to take a look. A hacker could
make a couple of minor revisions to the form and submit it as a
return credit transaction rather than an authorization. Naturally
the hacker will be returning money from your merchant account to his
own account.
To prevent this security breach, you must submit the form to an
interim script on your host server and the form should only include
information being provided by your customer. The interim script
is used to configure and send the information that has to be
passed to the processing gateway. In this way, the actual gateway
transaction is hidden from the client, preventing any altering.
Information that has to go to the gateway, but is generated earlier
in a session, should be available to the interim script using
server side variables, single threaded to the customer session. This
cannot be stated too strongly. Nothing should be in the credit card
form except the specific customer card information and a script for
checking the validity of the form content and blocking multiple submits.
CREDIT CARD FORM EXAMPLE
As an example, at ImagineNation we use an interim script to
call up the gateway and at the same time return an "in process" page
to the customer when a credit card form is submitted. This interim
page contains no vital information and is delivered to the client
browser using a window replace method so that there in no browser
history of the page.
When the gateway transaction concludes,
an action message is presented to the customer. If the transaction
is approved, the message is a confirmation and the session is killed.
At this stage, should the customer try the browser back button, they
will be returned to the credit card form. However, resubmitting the
form will result in an "access denied" message because the session is
no longer active.
If the transaction is declined, we return a declined message page
with the reason and allow the customer two more tries using a link on
the page back to the credit card form. There they can change
information or try using another card. This method protects us and
keeps the customer happy.
Often a customer will make a mistake
entering a card expiration date. There is no client or server side
way to check that this is the correct card date before submitting to
the gateway to process. Therefore, in the interest of customer
relations, we allow a limited number of retrys on declined cards while
at the same time preventing a hacker from trying many random
entries until finding one that works.
CONCLUSIONS
You may begin to see a pattern developing here. Protecting
information is a matter of creating layers of security policies,
procedures, and methods. No one thing you do is adequate in
itself. Your job is to make access to vital information increasingly
difficult for the hacker and unlikely for the inadvertent user and
mischief makers.
Forms are great, but without certain combined form and site design
considerations, they represent an easy target of opportunity for
even the unsophisticated hacker. They are also subject to innocent
human error during information entry. Take a little time
and think about the risks when creating a site using forms. Reducing
the risks is not hard; it just takes a little thoughtfulness in the
design.
COMMING UP
The final installment of this article will draw some overall
conclusions, look to the future, and explore myths about securing
information, including a big one that's pervasive throughout Internet.