What potential pitfalls can arise from using do_shortcode in a PHP code snippet?

Using do_shortcode in a PHP code snippet can potentially lead to security vulnerabilities if the content being passed through the shortcode is not properly sanitized. To avoid this, it is important to properly sanitize any user input before passing it through do_shortcode. One way to do this is by using the wp_kses function to ensure that only allowed HTML tags are included in the output.

$content = '<p>[my_custom_shortcode]</p>';
$allowed_tags = array(
    'p' => array(),
    'a' => array(
        'href' => array(),
        'title' => array()
    )
);

$sanitized_content = wp_kses($content, $allowed_tags);
echo do_shortcode($sanitized_content);