What are the potential security risks associated with using the headers "Content-Type: application/force-download" and "Content-Disposition: attachment" in PHP scripts?

Using the headers "Content-Type: application/force-download" and "Content-Disposition: attachment" in PHP scripts can potentially expose your application to security risks such as file disclosure vulnerabilities or malicious file downloads. To mitigate these risks, it is recommended to sanitize user input and validate file paths before sending them as attachments.

<?php
$file_path = '/path/to/your/file.pdf';

if (file_exists($file_path)) {
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename="' . basename($file_path) . '"');
    readfile($file_path);
    exit;
} else {
    echo 'File not found.';
}
?>