Results 1 to 9 of 9

Thread: security question

  1. #1
    Join Date
    Nov 2002
    Auburn, AL

    security question

    How safe does leaving request validtion on keep me? I mean would I be better off running replace statements on several harmful values that will go into a db, or should I keep it turned on? Some guy thought it would be fun to screw around on my clan site (got his ip, but that helps me none) and put in some bad values and then post in the news column you got hacked or some junk. Would keeping validate request on stop that? I am using mssql server 2000. I guess this question is mostly directed at cardboard hammer because we had that talk about deliminators and all.

  2. #2
    Join Date
    Nov 2003
    Request validation? I'll look up the details when I get in to work tomorrrow, but what exactly that equates to is a bit fuzzy for me at the moment..

    Anyhow, with user input going into a database and later being pulled to put text on a page, there are two major concerns: SQL injection and screwing up the HTML.

    To prevent SQL injection, either:
    --Use stored procedures and don't use EXEC on strings built from user input.
    --Replace "'" with "''" in all user supplied text used in a querystring.

    To prevent a user from tampering with the page's HTML (which can include putting malicious script into the page), use Server.HTMLEncode on all user supplied text that is to be written on the page. You can use Server.HTMLEncode either before storing the data to the database (only requires the overhead of encoding once) or after retrieving it (leaves the data as is so it is easier to use for general purposes).

  3. #3
    Join Date
    Nov 2002
    Auburn, AL
    Thanks for the tip on html encode. Ill do it when I get some free time... infact Ill do it now. Lemme google how to impliment it.
    HTML encode is just
    replace(string, "<", "&lt;")
    replace(string, ">", "&gt;")
    its just a tid bit shorter, but thats all it seems to do :/
    Last edited by PeOfEo; 07-22-2004 at 02:30 PM.

  4. #4
    Join Date
    Nov 2003
    To answer the original question, it doesn't look like validation is a simple cure to the issue. It appears that it's more convenient to handle validity as a seperate issue from textual content. If a string is supposed to have a certain format / length / whatever, validation is relevant to that. However, there may be legitimate reasons for a string to contain a "'" (punctuation in a sentence, for example) or other characters / combinations of characters that could cause problems if not treated correctly.

    If the admins here decided that a submitted post containing HTML tag(s) was invalid, there'd be a heavy burden on end users who wanted to post code samples... They'd have to do the encoding themselves.

  5. #5
    Join Date
    Nov 2003
    It also takes care of & as well, else "&lt;" would show up as "<".

  6. #6
    Join Date
    Nov 2002
    Auburn, AL
    Ok this guy still found a way into my site. I have no idea how he is getting in, like where the point of entry is. This is an annoyance. I am going to have to look over all of my code. It would help if I knew how hackers break into stuff to know how he is breaking in . You think you would be willing to help me fix this problem, like maybe look at a few files? Its really crappily done, its my early work and I was not getting paid, but I do not want to completely redo it, so I was just hopeing to find the holes without having to recode it all. I thought he was putting some malitious stuff into my data base, but now I am not sure, he could be brute forceing my login form or something because I revampt the registration from so you cant put in html, but there are no new entries, I deleted the old ones changed passes, but he is still using some of the other accounts. I might move to a cookie based login to eliminate a session problem. Got any tips for how to make a login form secure? Like disableing html is good for a registration form because the data can be redisplayed, but on a login form the data is not redisplayed, its just matched with the db. I am using mssql server btw, so he is not simply downloading an access mdb and looking at the contents.

    It looks like there was something like
    ' or 1=1 --
    as a session id, which I do not understand.

    I tried ' or 1=1 -- on my login form and it let me right in, very eye opening. I am going to replace some normal characters on that form, this is disturbing.
    Last edited by PeOfEo; 07-22-2004 at 10:45 PM.

  7. #7
    Join Date
    Nov 2002
    Auburn, AL
    ok, cardboard hammer, do you know an easy way to check that a text box has letters A-Z a-z numbers 0 - 9 and - _ . ~ and nothing else? I was thinking I would have to go in with string statements and try to replace all bad values, or loop through the string and check each letter. I was just wondering if you knew a function or some easier way to do it. I have never needed to do it so I do not know how. I can probably figure it out if I think about it for a bit. But I just do not want to do a bunch of scripting if there is a premade solution.

  8. #8
    Join Date
    Nov 2003
    I was gone from Thurs. night until just minutes ago, which is why I didn't reply sooner. I'll take a more careful look tomorrow, but replacing ' with '' in user input used to build querystrings (if you were using Access, you'd also need to replace " with "") and using Server.HtmlEncode on user input written to a page should be sufficient...

    ... I just looked again ... SQL injection is what's getting you: "' or 1=1 --" that turns the end of the query into " ... password = '' or 1=1 --'"

    EDIT: since you have SQL Server, you should use stored procedures instead of querystrings, as stored procedures offer better performance and better security against SQL injection (only using EXEC on a string built with user input would make a stored procedure vulnerable).
    Last edited by CardboardHammer; 07-24-2004 at 09:57 PM.

  9. #9
    Join Date
    Nov 2002
    Auburn, AL
    Ill look into stored procedures for future sites. Thanks.

    Of course, I will not be using login forms like this ever again, I will be using forms auth.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.17276 seconds
  • Memory Usage 2,921KB
  • Queries Executed 13 (?)
More Information
Template Usage (32):
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (9)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (9)postbit
  • (9)postbit_onlinestatus
  • (9)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (70):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • bbcode_parse_start
  • postbit_imicons
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates