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 7912441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:36:20+00:00 2026-06-03T13:36:20+00:00

I am referring the following article learning symbolic link attacks: struct stat st; FILE

  • 0

I am referring the following article learning symbolic link attacks:

struct stat st;
FILE * fp;
if (argc != 3) {
 fprintf (stderr, "usage : %s file message\n", argv [0]);
 exit(EXIT_FAILURE);
}

if (stat (argv [1], & st) < 0) {
 fprintf (stderr, "can't find %s\n", argv [1]);
 exit(EXIT_FAILURE);
}

if (st . st_uid != getuid ()) {
 fprintf (stderr, "not the owner of %s \n", argv [1]);
 exit(EXIT_FAILURE);
}

if (! S_ISREG (st . st_mode)) {
 fprintf (stderr, "%s is not a normal file\n", argv[1]);
 exit(EXIT_FAILURE);
}

sleep (25);

if ((fp = fopen (argv [1], "w")) == NULL) {
  fprintf (stderr, "Can't open\n");
  exit(EXIT_FAILURE);
}
 
fprintf (fp, "%s\n", argv [2]);
fclose (fp);
fprintf (stderr, "Write Ok\n");
exit(EXIT_SUCCESS);

Now when the program sleeps I rm the arg[1] (using another terminal ) which is the file name and then create a symbolic link for the same file. When I executed as its said in the article I am writing to the file the link is pointing into.

Then I used strace passed the same arguments its giving me "cant open" which means that I dont have access to the file passed as arg[1]. But this is not the case when I executed normally how is strace detecting this ?
Any help is very valuable.

I am writing my own application using ptrace to detect such attacks. I tried using inode numbers to detect this but my application is still referring to the inode number of the file which I am passing.

  • 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-06-03T13:36:22+00:00Added an answer on June 3, 2026 at 1:36 pm

    As discussed above, the binary was started with a suid flag (chmod u+s a.out). Since strace needs to watch the process, and can’t do that if it’s running as some other user, it will silently ignore s-bits.

    Solution: In the shell window where the program is run, use the login/user-id that would be used without strace – given that you just did chmod u+s a.out as that user, it should be a safe assumption that you can log in under that account.

    For completeness: To change your user id for a single shell window, just use su - otherlogin, replacing otherlogin with the log in name. (su = “switch user”)

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

Sidebar

Related Questions

Referring to the article here I created my .htaccess file with the following lines
I have tried to do this refering to following link. http://skypher.com/index.php/2008/07/28/function-list-for-php/ But no success.
Referring to Brian Goetz's article Are all stateful Web applications broken? for IBM developerWorks,
Referring here A is a precompiled Java class (I also have the source file)
I am referring to the following post : Excel distinct count with conditions I
Referring to this question, let's say we have the following scenario - A model
I am referring to the following source: http://clpbar.sourceforge.net Build process is the standard: ./configure
Referring to the discussion performSelector where is explained that with the following line it
I have been referring to the following page: http://msdn.microsoft.com/en-us/library/ms178129.aspx I simply want to bulk
By referring article, it is using a pair of volatile to prevent out-of-order execution.

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.