Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7735043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:24:05+00:00 2026-06-01T07:24:05+00:00

Is there any security risk of injection in the following PHP script? <?php $empfaenger_1

  • 0

Is there any security risk of injection in the following PHP script?

<?php
$empfaenger_1 = "test@example.com";
$sender = "test@example.com";

$name = $_POST['name'];
$telefon = $_POST['phone']; 
$betreff = "Test";

$text =
"Please contact me

Name: $name
Telefon: $telefon";

mail($empfaenger_1, $betreff, $text,"from:$sender");

$url = htmlspecialchars($_SERVER['HTTP_REFERER']);
echo "<center><br><br>Thank you<br><br>";
echo "<center><a href='$url'>Back</a>";
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T07:24:06+00:00Added an answer on June 1, 2026 at 7:24 am

    Injection in mail

    Here the risk appears minimal. A couple of answers here point to the possibility of HTML injection into the email. For HTML emails, this is a possibility, but HTML mail messages will have the Content-type header set to text/html or as a part of a multipart message. RFC 1521 stipulates that a HTML content-type must be set explicitly, and that if no content type is specified that plain text is default:

    Default RFC 822 messages are typed by this protocol as plain text in the US-ASCII character set, which can be explicitly specified as “Content-type: text/plain; charset=us-ascii”. If no Content-Type is specified, this default is assumed.

    In the above code, the user-provided text is inserted after the headers; an attacker would have no opportunity to change the content type (either to HTML or to multipart, the latter allowing injection of a MIME boundary).

    The end result cannot be anything but a plain text message. If a user injects HTML tags into the message, the person reading the email would see those HTML tags in the message. Email clients generally don’t opportunistically examine plaintext messages to locate and parse embedded HTML and JavaScript.

    Injection elsewhere

    While the use of mail is probably safe, there is a potential injection vulnerability in the remaining code:

    $url = htmlspecialchars($_SERVER['HTTP_REFERER']);
    echo "<center><a href='$url'>Back</a>";
    

    By default, htmlspecialchars uses the ENT_COMPAT | ENT_HTML401 flags, which does not convert single quotes to &#039;. The link href attribute is delimited with single quotes. So if an attacker can coerce the HTTP referrer to include a single quote, he/she can invoke a routine XSS attack. (for instance, if referrer is coerced into the equivalent of http://whatever/a' onclick='alert(), clicking the link can invoke arbitrary JavaScript. To resolve this, either place “$url” on the second line in double quotes, or call htmlspecialchars with the ENT_QUOTES flag.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am wondering if there is any potential security risk from the following code.
this is a 3 part question Is there any performance or security risk in
Is there any security risk in allowing a user to upload an HTML file
Could anyone please let me know if there are any major security risk for
Are there any security practices/techniques/considerations when, for example during (long/continuous) polling or normal requests
Are there any security exploits that could occur in this scenario: eval(repr(unsanitized_user_input), {__builtins__: None},
Are there any security issues keeping the .NET PDB files on the real server?
Are there any security concerns when putting an HTTPS iframe in an HTTPS page?
Are there any known security issues related to running a web application via a
Am wondering if there would be any security flaw in this approach. I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.