<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Dev-Blog of DoesntMatter &#187; Security</title>
	<atom:link href="http://dev-blog.doesntmatter.de/category/security/feed/" rel="self" type="application/rss+xml" />
	<link>http://dev-blog.doesntmatter.de</link>
	<description>Software technologies, tips, guides and tutorials</description>
	<lastBuildDate>Sun, 29 Apr 2012 12:57:20 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
		<item>
		<title>MySQL Security Tips</title>
		<link>http://dev-blog.doesntmatter.de/2012/02/26/mysql-security-tips/</link>
		<comments>http://dev-blog.doesntmatter.de/2012/02/26/mysql-security-tips/#comments</comments>
		<pubDate>Sun, 26 Feb 2012 14:26:36 +0000</pubDate>
		<dc:creator>DoesntMatter</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://dev-blog.doesntmatter.de/?p=390</guid>
		<description><![CDATA[In this post I will show up some dangers of the MySQL-Server usage you should care of. These are the first steps to enhance the security of your database server, because with this you are able to limit the access &#8230; <a href="http://dev-blog.doesntmatter.de/2012/02/26/mysql-security-tips/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>In this post I will show up some dangers of the MySQL-Server usage you should care of. These are the <em>first steps</em> to <strong>enhance the security</strong> of your database server, because with this you are able to <em>limit the access and the privileges</em>.</p>
<p><em>I recommend at least basic knowledge of MySQL to understand most of the things explained in the following part.</em></p>
<p><strong><u>Some dangers that people underestimate:</u></strong></p>
<ol>
<li><u>Empty passwords:</u></li>
<p>The first thing you should check and avoid on are empty passwords. On worst circumstance <strong>everyone can log on</strong> to your MySQL-Server!</p>
<p>With a simple SELECT-Statement you can check this and <strong>identify all users</strong> without any password.</p>
<p><code>SELECT User FROM mysql.user WHERE Password = <strong><span style="color: #ff0000;">""</span></strong>;</code></p>
<p>To solve this security issue you need to <strong>assign a password</strong> to the user with following UPDATE-statement.</p>
<p><code><em># Replace <strong>$PASS</strong> with the password<br />
# Replace <strong>$USER</strong> with the user</em><br />
UPDATE User SET Password=<strong><span style="color: #339966;">PASSWORD("$PASS")</span></strong> WHERE User="<strong>$USER</strong>";</code></p>
<li><u>Careless hosts settings:</u></li>
<p><code>CREATE USER 'user'@'<strong><span style="color: #ff0000;">%</span></strong>' IDENTIFIED BY 'password';</code></p>
<p>This is a bad example for creating an user in MySQL. The percent sign means that you can connect with this user from <strong>any</strong> host, what can have serious security impact.</p>
<p>There are better ways to do this. You can set exact IP-addresses, host-names or use wildcards for both ones to <strong>limit the connection possibilities of offenders significantly.</strong></p>
<p><code>CREATE USER 'user'@'<strong><span style="color: #339966;">localhost</span></strong>' IDENTIFIED BY 'password';<br />
CREATE USER 'user'@'<strong><span style="color: #339966;">10.11.%.%</span></strong>' IDENTIFIED BY 'password';</code></p>
<li><u>Lack of permissions:</u></li>
<p>The MySQL permission system is a very time consuming section. If you want to manage this correctly, you need to know all necessary permissions to every table in every database for every single user!</p>
<p>Because of this people often want to make their life easier and so they use a simple GRANT-statement, which sets all permissions. </p>
<p><code>GRANT <strong><span style="color: #ff0000;">ALL PRIVILEGES</span></strong> ON *.* TO 'user'@'host';</code></p>
<p>But, as you can imagine, this can have a very <strong>bad influence on your security</strong>. If your software is for example vulnerable for SQL-Injection and you do not know this, attackers can simply <strong>drop all databases</strong></strong>!<br />
To prevent this I recommend setting <strong>only the required privileges</strong> to the users.<br />
If you need an overview about all privileges you should have a look at the <a href="http://dev.mysql.com/doc/refman/5.5/en/privileges-provided.html" title="MySQL privileges" target="_blank">MySQL privileges section</a>. </p>
<p><code>GRANT <strong><span style="color: #ff9900;">SELECT,INSERT,UPDATE,DELETE ON *.*</span></strong> TO 'user'@'host';</code></p>
<p>A better way than only setting the limited permissions to all databases and tables is, setting <strong>different privileges for every table</strong>!</p>
<p><code>GRANT <strong><span style="color: #339966;">SELECT,INSERT,UPDATE,DELETE ON DB.TABLE</span></strong> TO 'user'@'host';</code></p>
<li><u>Bind-address in my.cnf file:</u></li>
<p>The bind-address restricts all connections to the MySQL-Server to a given IP-address.</p>
<p>In most cases you will see the line below commented out in the my.cnf file. This is necessary if you need to connect to the MySQL-Server from <strong>different hosts</strong>.</p>
<p><code><strong><span style="color: #ff0000;">#bind-address</span></strong>           = 127.0.0.1</code></p>
<p>But if you only need access to the MySQL-Server on localhost it is better and <strong>more secure</strong> to use this as bind-address, because the MySQL-Server does not listen on external connections then.</p>
<p><code><strong><span style="color: #339966;">bind-address</span></strong>           = 127.0.0.1</code>
</ol>
<p>I hope this tutorial helps you to secure your MySQL-Server. In fact there are much things you can do to make it more secure, but like I said this is a first step to enhance it.<br />
If you have feedback, regards, corrections or questions please let me know and do not hesitate to comment!</p>
]]></content:encoded>
			<wfw:commentRss>http://dev-blog.doesntmatter.de/2012/02/26/mysql-security-tips/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
