• brian (unregistered)

    There's an awful lot of not knowing about MS SQL server here too.

    First, xp_cmdshell won't even run on a default installation of SQL Server, since the SQL Server Agent must be running in the context of an actual account with specific privileges or it simply bails.

    Second, you can't back up the database device files while they are attached or the server is active, since they are locked for exclusive access (not even the backup process can read them). Since this was a public server, there's no way to take the database down for backup.

    Third, even if you used replication to another server, you'd still need stored procedures (or worse, administrative passwords in plaintext on the filesystem) to detach the device so the backup could run and reattach it after the backup finished.

    So yeah, the WTF here was that Tris offered to install something that was removed for "security reasons". Luke, being a droid, could only respond the way he did, as anyone who was offering to circumvent security was an obvious risk.

    The proper response for Tris would have been "I'm sorry, I can't do anything to help you. You're too stupid to deserve a backup."

  • (cs) in reply to Zygo
    Zygo:

    Stored procedures, especially unreviewed application-specific stored procedures, like all unreviewed application-specific code, usually don't survive very long under the scrutiny of deliberate attack. Contrast with any-old-SQL, which has security rules that are well understood

    Are you being deliberately daft? The vast majority of stored procs contain plain-old-sql: select, insert, update and delete statements. Exposing a limited set of plain-old-sql statements cannot be less secure than exposing arbitrary statements.

  • aggieben (unregistered) in reply to Sekret
    Sekret:
    The fact that our protagonist had CDs he didn't declare could have been cause for ejection and subsequent cavity searches.

    Indeed. This is surely the reason Tris was ordered to leave. He could have been arrested and interrogated. Luke did him a favor.

  • Jeff (unregistered) in reply to sir_flexalot
    sir_flexalot:
    Furthermore, rackmount monitors don't pull out...were they using an lcd and a keyboard on a tray?

    http://www.cases.tv/Rack_Monitor_Keyboard.jpg

  • Laurence (unregistered) in reply to FP

    That is true but isn't SQL server 2005 Shadow Copy Aware?

  • Laurence (unregistered) in reply to Laurence

    http://support.microsoft.com/kb/919023 Setting up volume shadow copy services for SQL Server 2005. This is a way to backup with no stored procedures and without the database passwords. In fact all that is needed is the user be part of the "Backup Users" group on the computer/domain.

    CAPTCHA waffles

  • Zygo (unregistered) in reply to gwenhwyfaer
    gwenhwyfaer:
    I'm not sure what you are advocating exactly, and if all you're saying is "don't assume your application is magically more secure just because you've stuck all your insecure bits in stored procedures", then whilst I might disagree (SQL injection attacks are much less likely, for one), it's a reasonable caution to voice. But if your argument is that stored procedures distribute security, whereas allowing the execution of arbitrary SQL presented by any client doesn't - sorry, but that's just silly; and since it appears to be your thrust, but I can't believe it's what you actually mean, I think you need to clarify even more than you've attempted to.

    Bah, I just re-read my own posts and even I'm not sure what I meant any more. ;-)

    So somehow I forgot that in addition to enabling CALL queries it is possible to disable all the other kinds of queries on many SQL server implementations. In theory you actually do get a security benefit with those servers if you strictly control the set of available stored procedures and disable other query types for all non-DBA roles, and if there isn't already some easier way to compromise the entire system.

    In practice, regardless of the DB's capabilities, I build a gateway system between the DB and the outside world which implements a much stricter protocol than the typical ODBC command channel. In my experience the first security task is to isolate the DB server from user-facing servers, since most successful attacks in the past have been targeted at the server itself. Once that's done the SP vs. SQL debate is moot since the client can't directly communicate with the server to attempt either. Tasks requiring more privilege than the gateway allows are executed from machines on the DB server side of the gateway.

    The "magically more secure" part is what I primarily disagreed with. All else being equal, switching to stored procedures instead of plain SQL isn't going to turn a convenience store into Fort Knox. It's more like switching from storing the store's cash in the register to storing the cash in a small wall safe in the manager's office. Neither is going to be effective if theives simply tear the safe out of the wall (get administrator access to the server and take over the DB process directly), or hold a gun to the manager's head until he opens the safe (subvert some random client machine on the LAN that the DBA uses and capture her password from the keyboard).

    I should also point out that my experience with non-PostgreSQL servers may include a disproportionately large number of systems that have already been compromised. Use of SP didn't help very much in that group--SP either forced attackers to use exploits at higher privilege levels than the DB server, or the SP's were the security problem in themselves. I've seen a stored procedure on a live server with a single text argument whose typical values looked like "SELECT+%2A+FROM+reports+ORDER+BY+repdate+OFFSET+10+LIMIT+10". Guess what the stored query does, and where the text comes from.

    PostgreSQL doesn't have an easy way to set an account such that it can only invoke stored procedures, much less only stored procedures from a fixed search path. You can create a variety of objects in PostgreSQL that grant users access to things they don't normally have access to. Views, for example, can expose data from tables that the owner of the view has read access to, but that the user executing SELECT against the view does not. Views don't have the search_path problem because of the way they are stored internally--their components are mapped directly to DB objects by numeric ID's so their meaning can't be changed by the user at run time. (The price for this is that the underlying tables can't be changed in several cases without first destroying the view.)

    Privileged stored procedures (which are the only kind that matters in PostgreSQL, since an unprivileged stored procedure can't do anything the user couldn't already do directly with SQL commands) are incredibly hard to get right even with search_path set as the advisory suggests. There are still nasty traps, like variable type declarations in PL/PgSQL, which are bound to (possibly user-defined) type and operator functions prior to executing commands in the procedure.

  • Adam (unregistered) in reply to darin

    No!!! NEVER backup a database by copying freaking binaries!!!! OMG!

    You back it up by dumping it to a text file. Period. Want to save space? Compress the text file with gzip or something.

  • anon (unregistered)

    reminds me a friend who would say "nice to meet you, i'm gonna eat your liver" to incautious consultants

  • Frank (unregistered) in reply to Gsquared
    Gsquared:
    And for those saying, "Use T-SQL to do the backups", please keep in mind that with no system stored procedures,
    AT blah OSQL backup_database?
    So, without the system stored procedures, and the errors in Enterprise Manager said they were missing the system stored procedures, you can't automate the backups from within SQL.
    Why would you want MSSQL to be responsible for backups. Heck, most shops re-script log shipping!
    You might be able to get a third party backup system running,
    yes, I call that "third party backup system" cmd.exe
    So, before you attack the author for wanting a few necessary system stored procedures, please, please, please actually understand what you're attacking.
    done and done
    "Sure, this database is so important that if it crashes the consequences are unimaginably bad, but go ahead and surf porn while the backup runs (if you can get it running). We don't have enough spyware, etc., on this server."
    A MSSQL server.... Connected to the internet? Have you completely lost your mind?

    Frank

  • Sharkie (unregistered)

    I don't understand the WTF here.. at all.

    As engineers we have to work with the Corporate philosophies that are more often rooted in complete insanity... but that doesn't change the fact that if we wish to have food on our table, and as the insanity seems to grow geometrically each year, we have to adapt and match those expectations.

    In this case, from the depiction- the consultant knew he was in an hostile environment, but at the end of the day, he had a job to do. This was to implement a backup scheme.

    The stored procedures issue was a challenge and Tris' inability to adapt was the source of the expulsion. When dealing with banks and/or government, no matter how insane the corporate requirements are, a good engineer will work around them and provide the result they want.

    In this case, the absence of stored procedures should have been queried rather than interjected... and when the answer to the query was due to security issues, the press to install them was also obviously the wrong answer. The rudeness in this case given the obvious animosity from the get-go I hang completely on Tris rather than Luke... especially given that Luke worked for an organization that the absence of stored procedures as being deemed "insecure" is likely just the icing on the cake folks like Luke had to work within every day. Government and Banks love to make any particular task 100 times more complicated and limited while, at the same time, pressing sky-high expectations on impossible timelines. This is the nature of the beast.

    Tris just was simply too green to establish this and was a fish out of water. Most consultants are and make this same mistake... hence why so many consultants are looked upon with contempt vs. embraced. If Tris had this "stuff", he wouldn't be consulting but lodged somewhere making larger sums and plowing through challenges with ease.

    How should this have gone? Upon the query of the missing procedures, the real result should have been. "Great, I have seen all I need to see and will now need to collect the remaining security and business requirements to implement the backup plan. Do you have a contact I may utilize for additional security issues as I implement the plan?" .. and brainstormed a mirror-split/offline mount/bulk copy/mirror-sync dump on a secondary server sharing the mirror (1 second downtime, no procedures needed).. and put a pricetag high enough to afford that dreamhome on the Riviera, including a nice sizeable kickback from the local hardware var for the secondary server.

  • ContractorInLivingHell (unregistered)

    Sounds like the NSA or maybe the bowels of the Pentagon, a DIA scene. That's what they are like. They are wooden, unfriendly, nasty people, many of whom are either just plain mean or in need of a lot of therapy to deal with their multiple psychiatric traumas from war or some other kind of government activities, or both. And, they're paranoid and highly classist, loving the fact that they "have a secret" and the rest of the world doesn't. They hate everyone who isn't exactly like them but of course would never admit it. They are awful people.

    Why am I not in gov't contracting work anymore, specifically spook-shop work? This is why.

  • run!@ (unregistered)

    Tris can consider himself lucky and Luke to be the hero that he was saving him from a hellish contract.

  • Nicolas V. (unregistered)

    If when they removed all the stored procedures their Web site did not crash, this means that everything was programmed with hard-coded SQL, which in itself is a security hole and plain bad programming.

    Now, removing the system stored procedures such as sp_adduser, that is beyond me. Where's the security hole? Unless you are dumb enough to allow Web users access to these procs and to run SQL code through the Web site, ... ?!?

    I think the kid is fortunate to have been shown the door.

    I also think the big dude was pissed because an outsider was involved and because he must be over-protective of his crap.

    Probably the Web developer himself, who thought he should have been the one to set up the backup and was forced to use somebody else.

    Happens more often than you might think.

  • Nicolas V. (unregistered) in reply to aggieben
    aggieben:
    Sekret:
    The fact that our protagonist had CDs he didn't declare could have been cause for ejection and subsequent cavity searches.

    Indeed. This is surely the reason Tris was ordered to leave. He could have been arrested and interrogated. Luke did him a favor.

    Yes, especially CDs with a Microsoft logo on them.

  • Nicolas V. (unregistered) in reply to brian
    brian:
    There's an awful lot of not knowing about MS SQL server here too.

    First, xp_cmdshell won't even run on a default installation of SQL Server, since the SQL Server Agent must be running in the context of an actual account with specific privileges or it simply bails.

    Second, you can't back up the database device files while they are attached or the server is active, since they are locked for exclusive access (not even the backup process can read them). Since this was a public server, there's no way to take the database down for backup.

    Third, even if you used replication to another server, you'd still need stored procedures (or worse, administrative passwords in plaintext on the filesystem) to detach the device so the backup could run and reattach it after the backup finished.

    So yeah, the WTF here was that Tris offered to install something that was removed for "security reasons". Luke, being a droid, could only respond the way he did, as anyone who was offering to circumvent security was an obvious risk.

    The proper response for Tris would have been "I'm sorry, I can't do anything to help you. You're too stupid to deserve a backup."

    Thanks for bringing some sanity and knowledge to the debate.

    Tris knew his stuff and offered a solution. Luke, if he acted the way he did, not saying "sorry, can't do that" or at least "please explain me why you want to reinstall the SPs" and "can't we back up without them?", is wrong.

    Luke's employer should expect him to look for the best solution and therefore to not be so stubborn.

    He was rude and unprofessional and his attitude will end up costing his employer.

  • Marcin (unregistered)

    Contractually, the dude got paid in full, right?

  • Simon Shine (unregistered) in reply to wiregoat

    It's got what SQL servers crave!

  • Jerim (unregistered) in reply to akatherder

    Yeah, there seems to be an entire dialogue missing from this story. It is as though the person forgot at least 5 good minutes of conversation. There had to be some sort of back and forth prior to being ordered to get out. Perhaps something along the lines of: "I can resintall them." "We don't want you to." "Well, I can't do this job without them." "Why not?" " "Only an idiot would ask that question." "Screw you." "Yeah? Well, your mother's a whore." "GET OUT!"

    Now the story makes more sense.

  • ohplz (unregistered) in reply to skippy
    skippy:
    Ever try backing up a live DB by simply copying the files? Might as well just kill the DB server mid-transaction and hope the db was in a safe state.

    :( The second method is fine. It's always in a safe state.

  • Random Drone (unregistered) in reply to jtl
    jtl:
    Even if they didn't want the DBA to use stored procedures, suddenly telling him to 'get out' when he suggests them is pretty messed up.

    Its not that he suggested change, its that he brought unauthorized software into the Secured Computing Facility. Probably walked past ALL KINDS of signs saying "No Unauthorized Media beyond this point..." And they weren't talking about reporters...

Leave a comment on “Government Department”

Log In or post as a guest

Replying to comment #:

« Return to Article