Este producto no es compatible con el sitio Datadog seleccionado. ().
Esta página aún no está disponible en español. Estamos trabajando en su traducción.
Si tienes alguna pregunta o comentario sobre nuestro actual proyecto de traducción, no dudes en ponerte en contacto con nosotros.

Metadata

ID: php-security/insecure-session-id

Language: PHP

Severity: Error

Category: Security

CWE: 340

Description

Session IDs are vital to maintaining state in your web applications and thus, it’s crucial to ensure that these IDs are secure and not easily guessable. If an attacker is able to predict or guess a session ID, they can hijack a user’s session, gain unauthorized access to their data, and perform actions on their behalf. This can result in severe data breaches and loss of trust from your users.

To avoid violating this rule, always generate sufficiently long and random session IDs. Also, avoid setting session IDs from user input, as this can open up the possibility for session fixation attacks.

Non-Compliant Code Examples

<?php
session_id(bin2hex(random_bytes(6)));
session_id($_POST["s_id"]);

Compliant Code Examples

<?php
session_id(bin2hex(random_bytes(16)));
session_regenerate_id();
https://static.datadoghq.com/static/images/logos/github_avatar.svg https://static.datadoghq.com/static/images/logos/vscode_avatar.svg jetbrains

Integraciones sin problemas. Prueba Datadog Code Security