{"id":3219,"date":"2013-02-07T15:32:59","date_gmt":"2013-02-07T05:32:59","guid":{"rendered":"http:\/\/www.flamingspork.com\/blog\/?p=3219"},"modified":"2013-02-07T15:32:59","modified_gmt":"2013-02-07T05:32:59","slug":"being-highly-irresponsible-or-howto-dos-nearly-all-rdbmss","status":"publish","type":"post","link":"https:\/\/www.flamingspork.com\/blog\/2013\/02\/07\/being-highly-irresponsible-or-howto-dos-nearly-all-rdbmss\/","title":{"rendered":"Being highly irresponsible (or, HOWTO DoS nearly all RDBMSs)"},"content":{"rendered":"<p>In my linux.conf.au 2013 talk, I had a big slide telling the audience how to do a simple Denial of Service attack against a MySQL server (post login). This was only one example of many others I could give, but I think it&#8217;s the simplest, and only requires the mysql command line tool and a single command. FYI, this also applies to PostgreSQL but I&#8217;ll leave the specifics up to somebody else to write.<\/p>\n<p>There is a fundamental flaw in just about all MVCC databases that leaves a giant Denial of Service attack hole. It is the following: START TRANSACTION WITH CONSISTENT SNAPSHOT followed by a bunch of waiting. Sine the database server has to maintain this read view, InnoDB will continue to grow UNDO until it has to extend the ibdata1 file (system table space).<\/p>\n<p>It&#8217;s important to remember that you cannot shrink the system table space (unlike with file-per-table where you can just do ALTER TABLE for any individual table suddenly finding itself a lot smaller).<\/p>\n<p>As UNDO grows, InnoDB will faithfully expand the system table space until ENOSPC and then everything will fall in a heap.<\/p>\n<p>In theory, you could have a system table space that doesn&#8217;t auto-extend, but then you&#8217;re relying on code paths to error out gracefully that I can pretty much bet you are completely untested.<\/p>\n<p>The only real way to avoid this is doing both of the following:<\/p>\n<ol>\n<li>Use kill-idle-transactions feature from Percona Server<\/li>\n<li>have a script that checks for long running transactions and just kills them.<\/li>\n<\/ol>\n<p>Similar things affect just about any MVCC database system. You&#8217;ll also see similar things with file system and volume manager snapshots.<\/p>\n<p>So is it highly irresponsible pointing this out? Of course it isn&#8217;t, this should be pretty well known to most DBAs already and so should a whole bunch of other things. Remember all the things you saw in production and then went to hit your developers over the head for? Well, they&#8217;re all in this same category.<\/p>\n<p>Go run giant UPDATEs, DELETEs or ALTER TABLE on a giant table in a replication setup, you&#8217;ll pretty much DoS your app as everything can&#8217;t get up to date read-only information from slaves.<\/p>\n<p>Considering that this is merely scratching the top of the iceberg of ways to DoS a database server, keeping post authentication crashing bugs secret just seems&#8230; well&#8230; futile, even if you do accept security through obscurity as valid.<\/p>\n<p>Further reading:<\/p>\n<ul>\n<li><a href=\"http:\/\/www.mysqlperformanceblog.com\/2010\/06\/10\/reasons-for-run-away-main-innodb-tablespace\/\">http:\/\/www.mysqlperformanceblog.com\/2010\/06\/10\/reasons-for-run-away-main-innodb-tablespace\/<\/a><\/li>\n<li><a href=\"https:\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/innodb-multi-versioning.html\">https:\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/innodb-multi-versioning.html<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>In my linux.conf.au 2013 talk, I had a big slide telling the audience how to do a simple Denial of Service attack against a MySQL server (post login). This was only one example of many others I could give, but &hellip; <a href=\"https:\/\/www.flamingspork.com\/blog\/2013\/02\/07\/being-highly-irresponsible-or-howto-dos-nearly-all-rdbmss\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[1],"tags":[],"class_list":["post-3219","post","type-post","status-publish","format-standard","hentry","category-general"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5a6n8-PV","jetpack-related-posts":[{"id":3801,"url":"https:\/\/www.flamingspork.com\/blog\/2014\/09\/19\/mysql-architecture\/","url_meta":{"origin":3219,"position":0},"title":"Some current MySQL Architecture writings","author":"Stewart Smith","date":"2014-09-19","format":false,"excerpt":"So, I've been looking around for a while (and a few times now) for any good resources that cover a bunch of MySQL architecture and technical details aimed towards the technically proficient but not MySQL literate audience. I haven't really found anything. I mean, there's the (huge and very detailed)\u2026","rel":"","context":"In &quot;mysql&quot;","block_context":{"text":"mysql","link":"https:\/\/www.flamingspork.com\/blog\/category\/work-et-al\/mysql\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3338,"url":"https:\/\/www.flamingspork.com\/blog\/2013\/05\/22\/some-storage-engine-features-you-only-get-if-youre-innodb\/","url_meta":{"origin":3219,"position":1},"title":"Some storage engine features you only get if you&#8217;re InnoDB","author":"Stewart Smith","date":"2013-05-22","format":false,"excerpt":"I had reason to look into the extended secondary index code in MariaDB and MySQL recently, and there was one bit that I really didn't like. MariaDB: share->set_use_ext_keys_flag(legacy_db_type == DB_TYPE_INNODB); MySQL: use_extended_sk= (legacy_db_type == DB_TYPE_INNODB); In case you were wondering what \"legacy_db_type\" actually does, let me tell you: it's not\u2026","rel":"","context":"In &quot;code&quot;","block_context":{"text":"code","link":"https:\/\/www.flamingspork.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3298,"url":"https:\/\/www.flamingspork.com\/blog\/2013\/04\/19\/detecting-if-a-mysql-server-supports-partitioning\/","url_meta":{"origin":3219,"position":2},"title":"Detecting if a MySQL server supports partitioning","author":"Stewart Smith","date":"2013-04-19","format":false,"excerpt":"This morning, this Percona XtraBackup bug came to my attention:\u00c2\u00a0https:\/\/bugs.launchpad.net\/bugs\/1170340\u00c2\u00a0- basically, it's now really quite tricky to determine if a MySQL server you're connected to supports partitioning or not. If you're connected to anything less than MySQL 5.6, you can use have_partitioning variable. But since that's gone in 5.6, you're\u2026","rel":"","context":"In &quot;mysql&quot;","block_context":{"text":"mysql","link":"https:\/\/www.flamingspork.com\/blog\/category\/work-et-al\/mysql\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":683,"url":"https:\/\/www.flamingspork.com\/blog\/2006\/04\/27\/dos\/","url_meta":{"origin":3219,"position":3},"title":"DOS","author":"Stewart Smith","date":"2006-04-27","format":false,"excerpt":"Denial Of Sushi Attack","rel":"","context":"In &quot;mysql&quot;","block_context":{"text":"mysql","link":"https:\/\/www.flamingspork.com\/blog\/category\/work-et-al\/mysql\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1131,"url":"https:\/\/www.flamingspork.com\/blog\/2008\/07\/01\/mysql-encrypted-online-backup-preview-1\/","url_meta":{"origin":3219,"position":4},"title":"MySQL Encrypted Online Backup Preview 1","author":"Stewart Smith","date":"2008-07-01","format":false,"excerpt":"I've just pushed to launchpad, a set of patches that implement AES encryption support for MySQL Online Backup. You will need to build --with-ssl to get support for encrypted online backup. Encrypted backup files have no recognisable header - they're just a stream of random bytes. Encryption and compression also\u2026","rel":"","context":"In &quot;General&quot;","block_context":{"text":"General","link":"https:\/\/www.flamingspork.com\/blog\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1650,"url":"https:\/\/www.flamingspork.com\/blog\/2009\/05\/27\/pluggable-metadata-stores-or-the-revenge-of-table-discovery\/","url_meta":{"origin":3219,"position":5},"title":"Pluggable Metadata stores (or&#8230; the revenge of table discovery)","author":"Stewart Smith","date":"2009-05-27","format":false,"excerpt":"Users of the ARCHIVE or NDB storage engines in MySQL may be aware of a MySQL feature known as \"table discovery\". For ARCHIVE, you can copy the archive data file around between servers and it magically works (you don't need to copy the FRM). For MySQL Cluster (NDB) it works\u2026","rel":"","context":"In &quot;drizzle&quot;","block_context":{"text":"drizzle","link":"https:\/\/www.flamingspork.com\/blog\/category\/work-et-al\/drizzle-work-et-al\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.flamingspork.com\/blog\/wp-json\/wp\/v2\/posts\/3219","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.flamingspork.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.flamingspork.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.flamingspork.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.flamingspork.com\/blog\/wp-json\/wp\/v2\/comments?post=3219"}],"version-history":[{"count":1,"href":"https:\/\/www.flamingspork.com\/blog\/wp-json\/wp\/v2\/posts\/3219\/revisions"}],"predecessor-version":[{"id":3220,"href":"https:\/\/www.flamingspork.com\/blog\/wp-json\/wp\/v2\/posts\/3219\/revisions\/3220"}],"wp:attachment":[{"href":"https:\/\/www.flamingspork.com\/blog\/wp-json\/wp\/v2\/media?parent=3219"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.flamingspork.com\/blog\/wp-json\/wp\/v2\/categories?post=3219"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.flamingspork.com\/blog\/wp-json\/wp\/v2\/tags?post=3219"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}