Is there any risk of an injection in the PHP mail () functions?

I am wondering if there is any potential security risk from the following code. I use this on my blog whenever a user posts a comment, he will send me a text message:

mail('cellnumber@messaging.sprintpcs.com', '',
     "Comment posted by $name: $comment",
     "From: comments@example.com");

Where $nameand $commentare user-entered values โ€‹โ€‹that were not actually sanitized in any way. Is there a chance that the user can do something evil here? The mail () documentation says nothing about this, but it is simply incorrect to enter user-entered values โ€‹โ€‹directly into a string. Is there a real risk or am I just paranoid?

+3
source share
3

, , , .

, , , , .

, , , , . SMTP CRLF , AFAIK, Unix , LF ( ). , .

+5

. (erm.. pardon my English, ) newlines " " SMTP.

, `\n.\n '( ) " ".

EDIT: , ! , $:

 someonesName
 CC: spamsubject@domain.com; anotherspamsubject@domain.com

(, -, )?

EDIT2: , "" "" . .

+3

PHP , , .

, , . , , .

PHP $XXX , XXX, ? $XXX - eval(), , , .

If SMTP does this internally, then .on one line, followed by an empty line, it will signal the end of the mail, and theoretically, an attacker could follow this text in the following lines to capture your mailbox, send another message to someone else. This is if PHP does not recognize and run away from such a string in the first place. This is what I would like to learn.

+2
source

Source: https://habr.com/ru/post/1727110/


All Articles