Improving the Security of the Application
The application is fully functional. Still, a rather obvious security problem exists as the application currently stands. The ColdFusion scripts on dante_quiz_results.cfm that insert the data into the database and output the scores on the page both depend on the URL variables. However, the address in the URL is fully editable!
1. | In the browser's address bar, change the score to 0 , and revise the username to the email address of someone you don't like. Press Enter or Return. |
The page reloads with the new data, and sure enough, your victim has been added to the database with a score of 0.[View full size image]

2. | In Dreamweaver, open dante_quiz_questions.cfm. In Design view, click to select the gray rectangle representing the Flash movie. In the Property inspector, click the Edit button. |
[View full size image]


3. | Click Frame 40 of the actions layer, and open the Actions panel. Revise the getURL() line to remove the variables, as follows: getURL("dante_quiz_results.cfm"); |
Now, no variables will be sent, which is not what you want. But you don't want the variables passed through the URL, so you'll have to remove them from the URL.The getURL() method, like many Flash methods, has optional parameters in addition to its required parameter (the URL itself). The two optional parameters are target and variables. The target parameter enables you to specify which browser window you want to open the requested URL. The default is the same window that called the file, or _self. If you don't specify a parameter, Flash assumes you mean _self as the target. The other parameter, variables, causes Flash to send all the variables on the timeline to the requested URL as part of the request. The variables parameter has only two options: GET and POST. You should recall the discussion about GET and POST earlier in a book, but as a quick review, GET sends the variables in the URL, while POST sends the variables as form data. So to retrieve data sent via GET in ColdFusion, you use #url.myVariable#, and to retrieve data sent via POST, you use #form.myVariable#. POST is the option you want.The only catch is that in order to specify this variables parameter, you also have to specify the target parameter, even though the default (_self) is fine.[View full size image]

4. | Revise the getURL() line one last time, as follows: getURL("dante_quiz_results.cfm", "_self", "POST"); |
Don't misspell anything or leave out any commas or quotes.Again, this line will send all the variables on the main timeline to dante_quiz_results.cfm, using POST.[View full size image]

5. | Click Done to return to Dreamweaver. Use the Files panel to upload (or put) dante_quiz.swf on the remote server. |
The SWF file is re-exported and the FLA is saved. Unfortunately, the SWF is not uploaded to the server, so you'll have to upload the SEF manually.One more change is necessary. The file dante_quiz_results.cfm is expecting two URL variables: username and score. You even created bindings for them. But they won't be available any more. Instead, they'll be available as form variables. You'll need to update dante_quiz_results.cfm, or you'll get errors.
6. | Open dante_quiz_results.cfm. Create bindings for two form variables: username and score (username might already exist; if so, don't redefine it). |
Dreamweaver now knows the data will be there, but the page is still looking for the wrong data.

7. | In the Document window in design view, click to select {URL.username}. In the Bindings panel, click the username variable in the Form category, and click Insert. Repeat the process to replace {URL.score} with {Form.score}. |
You've taken care of the <cfoutput> blocks. But don't test the file yet; remember there are two more places inside the <cfquery> block where the URL variable is used.[View full size image]

8. | Switch to code view, scroll to the top. Change #url.username# to #form.username#. Likewise, change #url.score# to #form.score#. |
Now the query will use available data as well.[View full size image]

9. | Save and upload dante_quiz_results.cfm. Take the whole quiz again, starting from dante_quiz_login.cfm. |
This time, when you get to the last page of the quiz, the username and score are both displayed and inserted into the database, but you can't edit them via the URL.[View full size image]
