您好,欢迎访问三七文档
部署安全的網站系統胡士亮平台架構技術副理台灣微軟開發工具暨平台推廣處提升安全性的方式Portblocking過濾加密修正程式更新IIS強化ACLsCASLoggingLeastprivilegeAccountmanagementValidationHashingEncryptionSecretsmanagementCookiemanagementSessionmanagementErrorhandlingSpoofedpackets,etc.Bufferoverflows,illicitpaths,etc.SQLinjection,XSS,inputtampering,etc.網路主機應用程式網路防禦主機防禦應用程式防禦停用通訊協定停用服務強化安全性資料庫SQLinjection,PasswordCracking,etc.資料庫防禦網路層威脅與弱點網路防禦強化防火牆i強化routers與switches加密敏感的網路傳輸保持最新的修正程式與更新停用不需要的連接埠和通訊協定使用filter拒絕有問題的連線保持最新的修正程式與更新使用filter拒絕spoofedpacketsScreenICMPtrafficfromtheinternalnetworkScreendirectedbroadcastrequestsfromtheinternalnetworkRejecttraceroutingrequests://msdn.microsoft.com/library/en-us/dnnetsec/html/SecNetHT18.asp主機層威脅UnsecuredOperatingSystemConfigurationUnmonitoredAccessExploitOperatingSystemWeaknessDistributeViruses主機防禦i保持最新的ServicePack與修正程式使用IISLockdown強化IIS5.0使用URLScan強化IIS5.0與IIS6.0DisablesFTP,SMTP,andNNTPRemoveskeyscriptmappingssuchas.idq,.htr,and.printerRemovesIISSamples,IISHelp,Scripts,andothervirtualdirectoriesACLssystemtoolsandWebcontentdirectoriestolimitaccessDisablesWebDAVInstallsURLScanLogsfailedrequestsLimitsrequestsizestomitigateDoSattacksMaskscontentheadersrevealingIIStypeandversionnumberBlocksrequestswithpotentiallyinjuriouscharacters(e.g.,dotsinpathnames)CanonicalizesandverifiespathnamestothwartdirectorytraversalattacksDisablesspecifiedverbs(e.g.,DEBUG)主機防禦強化Web主機TCP/IP使用最低權限帳號執行ASP.NET避免使用SYSTEMIIS6.0預設使用NetworkService限制檔案上傳大小configurationsystem.web!--Limitrequestlengthto128K(default=4MB)--httpRuntimemaxRequestLength=128//system.web/configuration主機防禦停用不需要的服務與共享強化使用者帳號刪除不需要的共享並限制存取權限停用不需要的服務與通訊協定(e.g.,SMBandNetBIOS)停用或是設定RemoteDataServices(RDS)安全性停用Guest帳號使用帳號原則設定複雜密碼將administratoraccount更換名字停用nullsessions(anonymouslogons)限制遠端登入開啟紀錄與稽核紀錄失敗的登入啟用系統失敗稽核使用NTFS存放IISlog稽核Metabase.bin存取主機防禦使用ACL限制重要資源的存取%systemroot%\System32d%systemroot%\Microsoft.NET\Framework%systemroot%\System32\LogfilesWeb內容目錄存放敏感資料的RegistryKey參考ASP.Net需要的NTFS權限文章=true#c19618429_025應用程式威脅與弱點應用程式防禦不要信任使用者輸入!使用安全的方式存取資料庫使用安全的方式存放敏感資料避免forms驗證的弱點保護ASP.NETsessionstate預期錯誤發生並妥善處理i驗證使用者輸入限制、拒絕、檢查所有輸入使用HTML-encode輸出使用者輸入的資料避免使用filenamesinput使用安全的編碼方式globalizationrequestEncoding=ISO-8859-1responseEncoding=ISO-8859-1/使用安全的方式存取資料庫使用storedprocedures或參數化的commands不要使用sa帳號存取資料庫安全的存放connectionstrings使用SSL/TLS或IPSec加密資料庫連線套用安全設定到SQLServer://msdn.microsoft.com/library/en-us/dnnetsec/html/SecNetHT19.asp帳號只供管理使用;絕對不要在程式中使用sa存取資料庫使用多個低權限帳號來存取資料庫查詢功能使用只有SELECT權限的帳號更好的方式是使用storedprocedure並且設定只允許EXECUTE權限在storedprocedure上減低攻擊者執行有害指令的能力建立一個低權限的帳號USELoginGO--AddaccountnamedwebusertoLogindatabaseEXECsp_addlogin'webuser','m1x2y3z4p5t6l7k8','Login'--GrantwebuseraccesstothedatabaseEXECsp_grantdbaccess'webuser'--Limitwebusertocallingproc_IsUserValidGRANTEXECUTEONproc_IsUserValidTOwebuserWindows驗證MicrosoftSQLServer支援兩種帳號驗證方式SQLServerloginsWindows帳號Windows驗證減低威脅機會不需要在connectionstrings內存放帳號密碼使用者帳號/密碼不會在網路上以非加密的方式傳送server=localhost;database=pubs;Trusted_Connection=yes使用安全的方式存放敏感資料存放敏感資料到資料庫或檔案應該要加密或是hashed信用卡號碼帳號密碼等要提升安全性,connectionstrings應該要加密加密在.Net中是很容易的System.Security.CryptographyclassesWindowsDataProtectionAPI(DPAPI)Forms驗證使用SSL/TLS保護帳號密碼不要存放密碼;存放密碼hashes不要依賴forms驗證來保護部署於ASP.NET的資源限制authenticationcookie存放期間以降低replayattack機會當存取敏感資料是要假設authenticationcookies已被冒用保護Logins將loginforms放在使用SSL/TLS的目錄中以避免網路擷取攻擊authenticationmode=FormsformsloginUrl=https://.../LoginPage.aspx//authenticationEncryptedconnection存放LoginPasswords格式說明Plaintextpasswords如果資料庫被入侵則所有帳號密碼都會被偷走Encryptedpasswords比plaintext好,但如過解密金鑰被竊取則還是會被取走1-waypasswordhashes比encrptedpassword好,但是仍會受到dictionaryattacks的威脅Saltedpasswordhashes不易受到dictionaryattacks不要用plaintext存放passwords存放加密過的密碼或密碼hashes來增加安全性PasswordHashesstringhash=FormsAuthentication.HashPasswordForStoringInConfigFile(password,SHA1));FormsAuthentication.HashPassword-ForStoringInConfigFile讓hashing變的容易SHA-1hashesMD5hashes建立SaltedHashesstringCreateSaltedPasswordHash(stringpassword){//GeneraterandomsaltstringRNGCryptoServiceProvidercsp=newRNGCryptoServiceProvider();byte[]saltBytes=newbyte[16];csp.GetNonZeroBytes(saltBytes);stringsaltString=Convert.ToBase64String(saltBytes);//AppendthesaltstringtothepasswordstringsaltedPassword=password+saltString;//Hashthesaltedpasswordstringhash=FormsAuthentication.HashPasswordForStoringInConfigFile(saltedPassword,SHA1);//AppendthesalttothehashstringsaltedHash=hash+saltString;returnsaltedHash
本文标题:部署安全的網站系統
链接地址:https://www.777doc.com/doc-1269980 .html