Changeset 7217


Ignore:
Timestamp:
Oct 31, 2016, 1:34:10 PM (6 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #2038: Taglibs in web client may leak information

Fixed the issue in Page taglib by making sure that variables are reset in the setPageContext method. Also added tag attribute sc for setting a session control on the page so that the taglib doesn't have to find out by inspecting the URL.

Also found similar issues with some variables in other taglibs that should be reset before used.

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/clients/web/net/sf/basedb/clients/web/taglib/Head.java

    r7197 r7217  
    239239  private void appendScripts(StringBuilder sb, JspContext jspContext)
    240240  {
    241     SessionControl sc = page.getSessionControl();
    242241    LinkedHashSet<String> allScripts = new LinkedHashSet<String>();
    243242
  • trunk/src/clients/web/net/sf/basedb/clients/web/taglib/Icon.java

    r6881 r7217  
    165165  private boolean enabled = true;
    166166 
    167   private boolean setEnabledIsCalled = false;
    168 
    169167  private int tabIndex;
    170168 
     
    198196  {
    199197    this.enabled = enabled;
    200     this.setEnabledIsCalled = true;
    201198  }
    202199  public boolean isEnabled()
  • trunk/src/clients/web/net/sf/basedb/clients/web/taglib/Page.java

    r7108 r7217  
    218218  */
    219219  private transient SessionControl sc;
     220  // TRUE if 'sc' has been set (including to null) in this page request
     221  private transient boolean scHasBeenSet;
    220222 
    221223  private transient JspContext skinContext;
     
    284286  }
    285287 
     288  /**
     289    Set the session control to use in this request.
     290    @since 3.10
     291  */
     292  public void setSc(SessionControl sc)
     293  {
     294    this.scHasBeenSet = true;
     295    this.sc = sc;
     296  }
     297 
     298  public SessionControl getSessionControl()
     299  {
     300    if (!scHasBeenSet && sc == null)
     301    {
     302      // Try to autoamtically get a session control
     303      try
     304      {
     305        scHasBeenSet = true;
     306        sc = Application.isRunning() ? Base.getSessionControl(pageContext.getRequest(), null, false) : null;
     307      }
     308      catch (RuntimeException ex)
     309      {}
     310    }
     311    return sc;
     312  }
     313 
    286314  public void setType(String type)
    287315  {
     
    352380  {
    353381    return BASE_VERSION;
    354   }
    355   public SessionControl getSessionControl()
    356   {
    357     return sc;
    358382  }
    359383
     
    382406  {
    383407    super.setPageContext(pageContext);
     408    // Reset variables that may exists since previous requests
    384409    favicon = null;
     410    sc = null;
     411    skinActions = null;
     412    skinContext = null;
     413    scHasBeenSet = false;
    385414    if (!initialized) initStaticFields(pageContext);
    386     try
    387     {
    388       sc = Application.isRunning() ? Base.getSessionControl(pageContext, false) : null;
    389     }
    390     catch (RuntimeException ex)
    391     {}
    392415  }
    393416
  • trunk/src/clients/web/net/sf/basedb/clients/web/taglib/tab/Tab.java

    r6881 r7217  
    2929import javax.servlet.jsp.JspException;
    3030import javax.servlet.jsp.JspTagException;
     31import javax.servlet.jsp.PageContext;
    3132import javax.servlet.jsp.tagext.BodyTagSupport;
    3233import javax.servlet.jsp.tagext.DynamicAttributes;
     
    288289    return dynamicAttributes == null ? null : dynamicAttributes.values().iterator();
    289290  }
     291 
     292  /**
     293    Reset the dynamic attributes to make sure old ones are not
     294    included in case the tag object is reused.
     295    @since 3.10
     296  */
     297  @Override
     298  public void setPageContext(PageContext pageContext)
     299  {
     300    dynamicAttributes = null;
     301    super.setPageContext(pageContext);
     302  }
    290303
    291304  @Override
  • trunk/src/clients/web/net/sf/basedb/clients/web/taglib/tab/TabControl.java

    r6881 r7217  
    329329    content = new StringBuilder();
    330330    initialTab = null;
     331    numTabs = 0;
    331332
    332333    if (!noTabs)
  • trunk/src/clients/web/net/sf/basedb/clients/web/taglib/table/Table.java

    r7083 r7217  
    385385      }
    386386    }
     387    else
     388    {
     389      sortColumns = null;
     390    }
    387391  }
    388392  public String getSortby()
     
    657661    }
    658662    definedColumns = new HashSet<String>();
     663    extensionColumns = null;
    659664
    660665    hiddenForm = new StringBuilder();
  • trunk/src/clients/web/net/sf/basedb/clients/web/taglib/table/Toolbar.java

    r6881 r7217  
    2626import javax.servlet.jsp.JspTagException;
    2727
    28 import net.sf.basedb.clients.web.Base;
     28import net.sf.basedb.clients.web.taglib.Page;
    2929import net.sf.basedb.clients.web.taglib.StylableTag;
    3030import net.sf.basedb.util.Values;
     
    172172  {
    173173    if (!isVisible()) return SKIP_BODY;
    174 
    175     SessionControl sc = null;
     174    Page page = (Page)findAncestorWithClass(this, Page.class);
     175   
     176    SessionControl sc = page != null ? page.getSessionControl() : null;
    176177    StringBuilder sb = new StringBuilder();
    177178
    178     sc = Base.getSessionControl(pageContext, false);
    179179    sb.append("<div");
    180180    addIdAndStyles(sb);
  • trunk/src/core/net/sf/basedb/core/Application.java

    r7166 r7217  
    10321032      throw new PermissionDeniedException("Invalid remoteId ("+remoteId+"; expected: "+sc.getRemoteId()+")");
    10331033    }
    1034     if (!sc.isAllowedToUseClient(externalClientId))
     1034    if (externalClientId != null && !sc.isAllowedToUseClient(externalClientId))
    10351035    {
    10361036      log.warn("getSessionControl: Invalid externalClientId: "+externalClientId+"; expected: "+sc.getExternalClientId());
  • trunk/www/WEB-INF/base.tld

    r6684 r7217  
    6666      <rtexprvalue>true</rtexprvalue>
    6767    </attribute>
     68    <attribute>
     69      <name>sc</name>
     70      <rtexprvalue>true</rtexprvalue>
     71    </attribute>
    6872  </tag>
    6973
Note: See TracChangeset for help on using the changeset viewer.