문제

어떤 유형의 입력 유형이 XSS (Cross-Site Scripting) 및 SQL 주입 공격에 가장 취약하지 않습니다.

PHP, HTML, BBCODE 등. 친구가 설정하는 것을 돕는 포럼에 대해 알아야합니다.

도움이 되었습니까?

해결책

귀하의 상황에 대해 더 알아야합니다. 취약한 방법? 항상해야 할 일 :

  • SQL 주입을 방지하기 위해 데이터베이스에 저장하기 전에 문자열을 탈출
  • HTML은 문자열이 알려지지 않은 소스에서 사용자에게 다시 인쇄 할 때 문자열을 인코딩하여 악의적 인 HTML/JavaScript를 방지합니다.

사용자가 제공 한 PHP를 실행하지는 않습니다. BBCode/UBBCode는 정의 적으로 올바른 HTML로 변환되기 때문에 정상입니다. 비록 기형 이미지 태그와 관련된 XSS 취약점을 살펴볼 수 있습니다. HTML 입력을 허용하는 경우 특정 요소를 화이트리스트에 올릴 수 있지만 이는 오류가 발생하기 쉬운 복잡한 접근 방식입니다. 그래서, 앞의 모든 것을 감안할 때, 나는 좋은 외부를 사용한다고 말할 것입니다. bbcode 도서관이 최선의 방법이 될 것입니다.

다른 팁

(방금 댓글에 이것을 게시했지만 몇몇 사람들은 선택 목록, 라디오 버튼 등을 소독 할 필요가 없다는 인상을 받고있는 것 같습니다.)

라디오 버튼이 안전하다고 믿지 마십시오. 서버의 데이터를 여전히 소독해야합니다. 사람들은 로컬 컴퓨터에서 HTML 페이지를 만들고 라디오 버튼과 동일한 이름의 텍스트 상자를 만들 수 있으며 해당 데이터가 다시 게시 될 수 있습니다.

보다 고급 사용자는 프록시와 같은 프록시를 사용할 수 있습니다 Webscarab, 매개 변수가 서버에 다시 게시 될 때 매개 변수를 조정합니다.

좋은 경험 법칙은 언제나 매개 변수화 된 SQL 문을 사용하십시오 언제나 HTML에 넣기 전에 사용자가 생성 한 데이터를 탈출하십시오.

그들 중 누구도 아닙니다. 서버에서 예상되는 모든 데이터는 지식과 동기 부여를 가진 사람들에 의해 조작 될 수 있습니다. 사람들이 사용하기를 기대하는 브라우저 및 양식은 서버/스크립트에 데이터를 제출하는 몇 가지 유효한 방법 중 하나 일뿐입니다.

XSS 및 관련 문제의 주제에 익숙해 지십시오.

모든 종류의 부울.

유효하지 않은 입력을 매우 쉽게 필터링 할 수도 있습니다.

;-)

There's lots of BB code parsers that sanitize input for HTML and so on. If there's not one available as a package, then you could look at one of the open source forum software packages for guidance.

BB code makes sense as it's the "standard" for forums.

The input that is the least vulnerable to attack is the "non-input".

Are you asking the right question?

For Odin's sake, please don't sanitize inputs. Don't be afraid of users entering whatever they want into your forms.

User input is not inherently unsafe. The accepted answer leads to those kinds of web interfaces like my bank's, where Mr. O'Reilly cannot open an account, because he has an illegal character in his name. What is unsafe is always how you use the user input.

The correct way to avoid SQL injections is to use prepared statements. If your database abstraction layer doesn't let you use those, use the correct escaping functions rigorously (myslq_escape et al). The correct way to prevent XSS attacks is never something like striptags(). Escape everything - in PHP, something like htmlentities() is what you're looking for, but it depends on whether you are outputing the string as part of HTML text, an HTML attribute, or inside of Javascript, etc. Use the right tool for the right context. And NEVER just print the user's input directly to the page.

Finally, have a look at the Top 10 vulnerabilities of web applications, and do the right thing to prevent them. http://www.applicure.com/blog/owasp-top-10-2010

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top