For a legacy Classic ASP application, I am supposed to remove all security attack issues. Currently, DB contains data which is already encoded and there will be no more Insert/update operations. Only select operations from now on wards.
I am able to remove SQL Injection and few other security issues, but, unable to remove
Cross Site Scripting (XSS) : Poor Validation Issue
This became bottle neck for delivery of the project.
Could anybody help me on this.
Example: My data in DB as following.
One Cell Sample Data (Korean and English Char)
1.. Rupture disc 설치 관련 필요 자재 List<BR>──────────────────────────────────────<BR>   No 필요 자재                            재질         비 고 <BR>──────────────────────────────────────<BR>   1 inlet isolation valve, 8"            Hast C276         기존 재고 사용 <BR>   2 RD holder inlet/outlet            Hast C276 / 316L     신규 구매 <BR>   3 Rupture Disc            Hast C276         신규 구매 <BR>   4 SV outlet isolation valve, 10"   SUS 316L         신규 구매 <BR>──────────────────────────────────────<BR><BR>2. Rupture Disc Specification<BR>  1) Rupture design press  : 4kg/cm2<BR>  2) Design temperature  : 100℃<BR>  3) Rupture press tolerance                  : ± 5%<BR>  4) Manufacturing range  : + 0%,   - 10%<BR>  5) Material spec   : M1, M4, C31<BR>  6) Max. allowable oper press                 : 3.2kg/cm2 (at 100℃)<BR><BR>3. Rupture Disc spec 선정 기준<BR>  . Code,  Standard = API 520,  ASME VIII<BR>  . Required Burst Pressure = Vessel Design Pressure<BR>  . Manufacturing range(+0% ∼ -10%) of Required Burst Pressure<BR>  . Rupture Pressure Tolerance +5%, -5% of Stamped Burst Pressure<BR>  . Specified Disc Temperature = Actual Temperature of Disc in Operation <BR>    → usually lower at disc than in liquid phase of vessel  <BR><BR>4. Rupture Disk 전단 및 SV2209 후단 Isolation valve는 CSO(CAR SEAL OPEN) .<BR><BR>5. Rupture Disk 후단에 PG2209를 설치하여 운전 중 Rupture disk 파손 여부 확인 가능토록 함.<BR>
I am displaying above cell data as follows:
Sample Page:
<!-- #include file="INCLUDES/HTMLDecode.inc" -->
.
.
.
<HTML>
.
.
.
sampledata = rs("sampledata")
.
.
.
<TD><%= ClearForAttack(sampledata) =%></TD>
.
.
.
</HTML>
The above functions defined as follows :
User Defined Functions:
    <%
    Function HTMLDecode(sText)
        Dim I
        sText = Replace(sText, """, Chr(34))
        sText = Replace(sText, "<"  , Chr(60))
        sText = Replace(sText, ">"  , Chr(62))
        sText = Replace(sText, "&" , Chr(38))
        sText = Replace(sText, " ", Chr(32))
        For I = 1 to 255
            sText = Replace(sText, "&#" & I & ";", Chr(I))
        Next
        HTMLDecode = sText
    End Function
    %>
    <%
    Function ClearForAttack(pStrValue)
        if len(pStrValue)>0 then
            pStrValue = HTMLDecode(Server.HTMLEncode(pStrValue))
            pStrValue = replace(pStrValue,"'","")
            pStrValue = replace(pStrValue,"`","")
            pStrValue = replace(pStrValue,"%","")
            pStrValue = replace(pStrValue,"<","<")
            pStrValue = replace(pStrValue,">",">")
        else
            pStrValue = ""
        end if
        ClearForAttack = pStrValue
    End Function
    %>
To display already encoded data I am using both HTMLDecode and HTMLEncode Functions
Please EDIT functions or suggest me another approach.
Your help or suggestions are highly appreciated.
Thanks in advance.
 
     
     
    