In response to my article on the Flash Data Connection Kit (at http://www.macromedia.com/devnet/mx/coldfusion/articles/data_conn.html) many of you have written to me asking about comments I made as to how to use (or not use) the Firefly components in production environments. Some of the specific questions pertain to my recommending that the SQL Connector not be used, that a generic XML delta packet processor not be implemented, and that table names or other database specific information not be embedded directly in the Flash application. The truth of the matter is that the validity of my concerns really depends on where the application is being used, and whether or not it is being used in a trusted environment (by trusted users). There is nothing inherently wrong or bad in doing any of those things that I advised against, but doing so does require making some core assumptions that worry me. The underlying concern here is this: I have a fundamental problem with anything running on the client side of an HTTP connection being able to directly affect SQL statements being executed against a database. Put it this way, would you ever display the SQL that your application page were to execute in an editable box? Of course you wouldn't. You'd also (I hope) never pass URL parameters directly to SQL without carefully checking them first. And you'd never embed table names or SQL in generated HTML. Ever. Flash may be a bit different in that it is a little harder to browse and change what is in Flash than it is an HTML page, but it is not impossible. Furthermore, Flash Remoting runs over HTTP and it is not impossible for a client other than Flash to pretend to be something that it is not. The fact of the matter is, embedding SQL in Flash essentially requires that ColdFusion (or Java or .NET) on the server pass that SQL to a back-end DBMS for processing. That requires faith that the client has not been tampered with in any way, and I'd suggest that such faith is inherently risky. Even writing a generic XML delta packet parser (one that will handle inserts and updates and deletes for tables and columns specified in the XML delta packet itself) is dangerous. It would not be difficult to submit SQL to get back all primary keys (or simply browse Web pages to look for primary keys, as these are often used as URL parameters in data drill-down interfaces), and then submit a malicious delta packet that would execute DELETE statements for all of those keys. Flash SWF files may be compiled into a binary form that is not human readable or writable, but don't let that create a false sense of security. It is possible to decompile SWF files, it is possible to fake being Flash talking to Flash Remoting, and it is possible to send fake XML delta packets. This is not a limitation of Flash, rather, it is part of the very nature of HTTP. Flash, like a Web browser, is bound by the behavior of HTTP. Flash can be useful and valuable as the client side of an HTTP based client-server application, but it is best to treat Flash as you would any HTTP client, and not make dangerous or naive assumptions. And thus my comments in that article. Of course, every rule is made to be broken, and in known trusted environments it may indeed be acceptable to embed SQL statements in Flash or arbitrarily process XML generated SQL in ColdFusion. But my gut feel is that this should be considered the exception, not the norm.
Responding to Feedback on my "Flash Data Connection Kit" Article
7 Comments
S
Sudhaman Srinivasan
is there a FlashMX/DataConnectionKit/Remoting/CFMX WACK in the pipeline?
B
Ben Forta
No, not a dedicated book on all of those. But there is a book on Flash in the works that should be what you want.
B
Ben Forta
The book is being written by Nate Weiss (my CFWACK coauthor, and one of the best tech writers I know). It is tentatively called "Flash for Server Geeks" :-). I don''t know what the release date is, but keep an eye on his web page http://www.nateweiss.com/.
D
David Franco
What and when, pray tell, is the name of this book and its expected completion?
J
Jack Phillips
Ben, there seems to be some little problem with Flash Data Connection Kit tutorial. I and several others went through it and came to the same end. We can add, edit and view the delta packets, but the responder won't actually save the data to the DB. On the last page you invoke 'doSave'. (Call saveUpdates)
Up until that point, everything went very well, but no saved data. I am also trying to find reference to 'saveUpdates'. It is only mentioned one other time on the MM site. There is a hack being discussed on the MM forum but it is going in the wrong direction. I have $600 of mine and my bosses money into the FF Flash Data Connection Kits and I have been making a fool of my self trying to get something to show him for his money. I just want to add, edit, and delete data from a database, from a FF interface to justify the expense for the software. Can you please help us? Did you actually get data to save?
B
Ben Forta
Jack. I ran through every step, and it does indeed update. The suggestion in the forum is incorrect, you do need need to add the deltaData arg, it is there by default, and the default setting is correct. The only explicit parameter that you need for the updates to work is identifying the primary key in the resolver.
G
Gary Spaniola
Ben, I went over the tutorial many times and I can't get the users.cfc to insert data. What am I missing.
Thanks - Gary