Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7417821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:46:17+00:00 2026-05-29T07:46:17+00:00

This is a security issue I’m trying to figure out. Everything works fine and

  • 0

This is a security issue I’m trying to figure out. Everything works fine and I can get users authenticated to Twitter from inside my managed package destined for the AppExchange. The problem is that the Twitter OAuth 1.0 process (or “dance”) has communication steps that occur with GETs coming from Twitter back into my application. Although this works, it’s a red flag for the security review process according to security test passes online and now with CxViewer in Eclipse.

But I need to get this information from Twitter and store it somehow for each user. A sample code entry point with this issue, where Twitter is calling back from one of my auth_token requests, would be:

Page:

<apex:page controller="AuthController" action="{!completeAuthorization}"/>

Apex:

public PageReference completeAuthorization() 
{
   String token = ApexPages.currentPage().getParameters().get('oauth_token');
   CustomObject__c c = new CustomObject__c(Name = token);
   insert c; // <--- Security flaw here! (except that it's Twitter, not Trojan.com)
}

I’ve read all the supplied Apex documentation on the subject, read it again, looked through the forums and unfortunately came up with zilch/nada. Any assistance would be greatly appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T07:46:18+00:00Added an answer on May 29, 2026 at 7:46 am

    Here’s what I discovered. The issue relates to having the GET parameter dictate anything about the object selected in Salesforce and then saving data to that object. I don’t believe there was ever a real security issue and with my new code the security test passes with no problem. What was happening is essentially this:

    String token = ApexPages.currentPage().getParameters().get('oauth_token');
    
    CustomObject__c pcs = [
    SELECT Id, User__c, Token__c 
    FROM CustomObject__c 
    WHERE Id = :UserInfo.getUserId() 
    AND Token__c = :EncodingUtil.urlEncode(token, 'UTF-8'];
    

    Since this whole exchange begins from my context, where I’m 100% certain of the current user (UserInfo.getUserId()), I don’t need to check whether this particular token matches since the user is guaranteed (at least as it relates to me initiating this process). So the following select works fine:

    CustomObject__c pcs = [
    SELECT Id, User__c, Token__c 
    FROM CustomObject__c 
    WHERE Id = :UserInfo.getUserId()];
    

    Then later if I do an update to this object:

    update pcs;
    

    it doesn’t complain since the GET value passed in doesn’t have any connection with the object chosen for the write. As you might notice, however, there never really was a problem – as long as I included

    WHERE Id = :UserInfo.getUserId()
    

    to the SOQL statement. The reason is that no matter what false tokens an attack tried to inject into my code, it was still verifying against the current user and would fail in any case if the user didn’t match. But in Salesforce there’s no possible way to have two simultaneous users logged in at the same time, like most systems, so the token check was overkill from the start, since I’m never sharing my User Ids with Twitter.

    The actual tokens that need to be stored (oauth_token and oauth_secret) can be retrieved as POST parameters and therefore have built-in Salesforce CSRF protection. These are retrieved like this:

    Http h = new Http();
    HttpRequest req = new HttpRequest();
    req.setMethod('POST');
    req.setEndpoint(accessTokenURL);
    req.setBody('');
    sign(req);
    HttpResponse res = new HttpResponse();
    String resParams = res.getBody();
    Map<String,String> rp = new Map<String,String>();
    
    if(resParams != null)
    {
       for(String s : resParams.split('&')) 
       {
          List<String> kv = s.split('=');
          rp.put(kv[0],kv[1]);
       }
    }
    
    tK.Secret__c = rp.get('oauth_token_secret');
    tK.Token__c = rp.get('oauth_token');
    
    upsert tK; // No problem, it's from a POST body
    

    And I was about to POST a bounty 😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It's an important security issue and I'm sure this should be possible. A simple
This is a javascript security question: suppose a page finds out the screen resolution
This is obviously a security issue and probably do not want to change this,
This is a really odd security issue with a C# (3.0) Console application. The
Update: This issue has been resolved. you can read about the solution in here:
Regarding this security issue: http://techcrunch.com/2010/10/24/firesheep-in-wolves-clothing-app-lets-you-hack-into-twitter-facebook-accounts-easily/ Is it true to say any time a user
I'm trying to use IIS 7 management API but stuck with a security issue.
This is a security best practice and I'm wondering if I should even be
The answer to this question: Declarative Security--what's this? Doesn't really tell me much... doesn't
this is part of a security audition , so there is no way to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.