Beneficios de seguridad de la creación de procedimientos almacenados mysql

Contents

Creating MySQL stored procedures involves creating a set of SQL statements, Name and store them in MySQL as a group. This way it can be reused and shared by multiple programs, while also gaining some important advantages.

istock-693216672-3783833

Photo credits: Peterpal

One of the most beneficial reasons to create MySQL stored procedures is the additional layer of security. that is placed on the database of the application requesting data. If the user account created for the application or web portal is set up with execution-only permissions, the user account will not be able to directly access the following tables.

This helps prevent a hacker from directly accessing the database tables. El riesgo en el que se incurre si un pirata informático utiliza esa cuenta de usuario que ejecuta un procedimiento almacenado es mucho menor que con una cuenta de usuario que tiene permisos completos de inserción, actualización y eliminación de forma directa en las tablas.

Control de acceso al crear procedimientos almacenados mysql

In practice, al crear procedimientos almacenados de mysql, es factible usar algunas reglas que facilitan el control de la cuenta Puede especificar un usuario en un atributo DEFINER de objeto. These are the following:

  • Que solo es factible especificar un valor DEFINER que no sea su propia cuenta, si tiene el SÚPER privilegio.
  • Que el único valor de usuario legal para todos los que no disponen el privilegio SUPER es su propia cuenta, whether it has been specified literally or through the use of CURRENT_USER, making it impossible to set the definer to any other account.

Another advantage of creating MySQL stored procedures is that it can minimize the potential risk of the stored program and see the creation and usage. To do this, simply follow these guidelines:

  • Use the SQL SECURITY INVENTORY in the object definition whenever feasible for a stored routine or view, since this can only be used by users with the appropriate privileges for the operations performed by the object.
  • Specify an explicit DEFINER attribute when creating stored programs or views in the context of the definer, while using an account that has the SUPER privilege, since that attribute will refer to an account that only has the privileges required for the operations performed by the object. Only in cases where it is absolutely necessary, an account with many privileges could be specified as DEFINER.
  • Prevent users from specifying DEFINER accounts with many privileges, something that, as administrators, this can be achieved by creating MySQL stored procedures, as long as they are not granted the SUPER privilege.
  • Describe objects in the DEFINER context considering that they may have access to data for which the invoking user does not have privileges. In some cases, reference to these objects can be avoided if specific privileges are not granted to unauthorized users. For this, It would be enough to determine that users without the EXECUTE privilege cannot refer to stored functions or procedures, and that users with the appropriate privilege can never refer to a view (as would be the case, as an example, of SELECT for select or INSERT for insert).

Despite this, do not forget that this type of security measure when creating MySQL stored procedures cannot be applied to triggers and events, since they do not have an SQL SECURITY feature and always run in a definitional context, so there is no user to refer to them directly.

(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = “//connect.facebook.net/es_ES/all.js#xfbml=1&status=0”;
fjs.parentNode.insertBefore(js, fjs);
}(document, ‘script’, 'facebook-jssdk'));

Subscribe to our Newsletter

We will not send you SPAM mail. We hate it as much as you.

Datapeaker